@ -879,7 +879,7 @@ Object.defineProperty(Url.prototype, 'port', {
return null ;
} ,
set : function ( v ) {
if ( v === null ) {
if ( isConsideredEmpty ( v ) ) {
this . _ port = - 1 ;
if ( this . _ host )
this . _ host = null ;
@ -941,7 +941,7 @@ Object.defineProperty(Url.prototype, 'path', {
return ( p == null && s ) ? ( '/' + s ) : null ;
} ,
set : function ( v ) {
if ( v === null ) {
if ( isConsideredEmpty ( v ) ) {
this . _ pathname = this . _ search = null ;
return ;
}
@ -973,7 +973,7 @@ Object.defineProperty(Url.prototype, 'protocol', {
return proto ;
} ,
set : function ( v ) {
if ( v === null ) {
if ( isConsideredEmpty ( v ) ) {
this . _ protocol = null ;
} else {
var proto = '' + v ;
@ -1001,7 +1001,7 @@ Object.defineProperty(Url.prototype, 'href', {
var parsesQueryStrings = this . _ parsesQueryStrings ;
// Reset properties.
Url . call ( this ) ;
if ( v !== null && v !== '' )
if ( ! isConsideredEmpty ( v ) )
this . parse ( '' + v , parsesQueryStrings , false ) ;
} ,
enumerable : true ,
@ -1013,7 +1013,7 @@ Object.defineProperty(Url.prototype, 'auth', {
return this . _ auth ;
} ,
set : function ( v ) {
this . _ auth = v === null ? null : '' + v ;
this . _ auth = isConsideredEmpty ( v ) ? null : '' + v ;
this . _ href = '' ;
} ,
enumerable : true ,
@ -1026,7 +1026,7 @@ Object.defineProperty(Url.prototype, 'host', {
return this . _ host ;
} ,
set : function ( v ) {
if ( v === null ) {
if ( isConsideredEmpty ( v ) ) {
this . _ port = - 1 ;
this . _ hostname = this . _ host = null ;
} else {
@ -1053,7 +1053,7 @@ Object.defineProperty(Url.prototype, 'hostname', {
return this . _ hostname ;
} ,
set : function ( v ) {
if ( v === null ) {
if ( isConsideredEmpty ( v ) ) {
this . _ hostname = null ;
if ( this . _ hasValidPort ( ) )
@ -1080,7 +1080,7 @@ Object.defineProperty(Url.prototype, 'hash', {
return this . _ hash ;
} ,
set : function ( v ) {
if ( v === null ) {
if ( isConsideredEmpty ( v ) || v === '#' ) {
this . _ hash = null ;
} else {
var hash = '' + v ;
@ -1100,7 +1100,7 @@ Object.defineProperty(Url.prototype, 'search', {
return this . _ search ;
} ,
set : function ( v ) {
if ( v === null ) {
if ( isConsideredEmpty ( v ) || v === '?' ) {
this . _ search = this . _ query = null ;
} else {
var search = escapeSearch ( '' + v ) ;
@ -1125,7 +1125,7 @@ Object.defineProperty(Url.prototype, 'pathname', {
return this . _ pathname ;
} ,
set : function ( v ) {
if ( v === null ) {
if ( isConsideredEmpty ( v ) ) {
this . _ pathname = null ;
} else {
var pathname = escapePathName ( '' + v ) . replace ( /\\/g , '/' ) ;
@ -1144,6 +1144,10 @@ Object.defineProperty(Url.prototype, 'pathname', {
configurable : true
} ) ;
function isConsideredEmpty ( value ) {
return value === null || value === undefined || value === '' ;
}
// Search `char1` (integer code for a character) in `string`
// starting from `fromIndex` and ending at `string.length - 1`
// or when a stop character is found.