@@ -879,7 +879,7 @@ Object.defineProperty(Url.prototype, 'port', {
879
879
return null ;
880
880
} ,
881
881
set : function ( v ) {
882
- if ( v === null ) {
882
+ if ( isConsideredEmpty ( v ) ) {
883
883
this . _port = - 1 ;
884
884
if ( this . _host )
885
885
this . _host = null ;
@@ -941,7 +941,7 @@ Object.defineProperty(Url.prototype, 'path', {
941
941
return ( p == null && s ) ? ( '/' + s ) : null ;
942
942
} ,
943
943
set : function ( v ) {
944
- if ( v === null ) {
944
+ if ( isConsideredEmpty ( v ) ) {
945
945
this . _pathname = this . _search = null ;
946
946
return ;
947
947
}
@@ -973,7 +973,7 @@ Object.defineProperty(Url.prototype, 'protocol', {
973
973
return proto ;
974
974
} ,
975
975
set : function ( v ) {
976
- if ( v === null ) {
976
+ if ( isConsideredEmpty ( v ) ) {
977
977
this . _protocol = null ;
978
978
} else {
979
979
var proto = '' + v ;
@@ -1001,7 +1001,7 @@ Object.defineProperty(Url.prototype, 'href', {
1001
1001
var parsesQueryStrings = this . _parsesQueryStrings ;
1002
1002
// Reset properties.
1003
1003
Url . call ( this ) ;
1004
- if ( v !== null && v !== '' )
1004
+ if ( ! isConsideredEmpty ( v ) )
1005
1005
this . parse ( '' + v , parsesQueryStrings , false ) ;
1006
1006
} ,
1007
1007
enumerable : true ,
@@ -1013,7 +1013,7 @@ Object.defineProperty(Url.prototype, 'auth', {
1013
1013
return this . _auth ;
1014
1014
} ,
1015
1015
set : function ( v ) {
1016
- this . _auth = v === null ? null : '' + v ;
1016
+ this . _auth = isConsideredEmpty ( v ) ? null : '' + v ;
1017
1017
this . _href = '' ;
1018
1018
} ,
1019
1019
enumerable : true ,
@@ -1026,7 +1026,7 @@ Object.defineProperty(Url.prototype, 'host', {
1026
1026
return this . _host ;
1027
1027
} ,
1028
1028
set : function ( v ) {
1029
- if ( v === null ) {
1029
+ if ( isConsideredEmpty ( v ) ) {
1030
1030
this . _port = - 1 ;
1031
1031
this . _hostname = this . _host = null ;
1032
1032
} else {
@@ -1053,7 +1053,7 @@ Object.defineProperty(Url.prototype, 'hostname', {
1053
1053
return this . _hostname ;
1054
1054
} ,
1055
1055
set : function ( v ) {
1056
- if ( v === null ) {
1056
+ if ( isConsideredEmpty ( v ) ) {
1057
1057
this . _hostname = null ;
1058
1058
1059
1059
if ( this . _hasValidPort ( ) )
@@ -1080,7 +1080,7 @@ Object.defineProperty(Url.prototype, 'hash', {
1080
1080
return this . _hash ;
1081
1081
} ,
1082
1082
set : function ( v ) {
1083
- if ( v === null ) {
1083
+ if ( isConsideredEmpty ( v ) || v === '#' ) {
1084
1084
this . _hash = null ;
1085
1085
} else {
1086
1086
var hash = '' + v ;
@@ -1100,7 +1100,7 @@ Object.defineProperty(Url.prototype, 'search', {
1100
1100
return this . _search ;
1101
1101
} ,
1102
1102
set : function ( v ) {
1103
- if ( v === null ) {
1103
+ if ( isConsideredEmpty ( v ) || v === '?' ) {
1104
1104
this . _search = this . _query = null ;
1105
1105
} else {
1106
1106
var search = escapeSearch ( '' + v ) ;
@@ -1125,7 +1125,7 @@ Object.defineProperty(Url.prototype, 'pathname', {
1125
1125
return this . _pathname ;
1126
1126
} ,
1127
1127
set : function ( v ) {
1128
- if ( v === null ) {
1128
+ if ( isConsideredEmpty ( v ) ) {
1129
1129
this . _pathname = null ;
1130
1130
} else {
1131
1131
var pathname = escapePathName ( '' + v ) . replace ( / \\ / g, '/' ) ;
@@ -1144,6 +1144,10 @@ Object.defineProperty(Url.prototype, 'pathname', {
1144
1144
configurable : true
1145
1145
} ) ;
1146
1146
1147
+ function isConsideredEmpty ( value ) {
1148
+ return value === null || value === undefined || value === '' ;
1149
+ }
1150
+
1147
1151
// Search `char1` (integer code for a character) in `string`
1148
1152
// starting from `fromIndex` and ending at `string.length - 1`
1149
1153
// or when a stop character is found.
0 commit comments