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