forked from nodejs/node
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
url: fix treatment of some values as non-empty
In addition to null, undefined and the empty string are treated as empty (removing the component from the url). The string '#' is treated same as empty values when setting .hash. The string '?' is treated same as empty values when setting .search. Fixes nodejs#1588
- Loading branch information
1 parent
7702b0d
commit e274b92
Showing
2 changed files
with
61 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,10 +43,10 @@ const accessorTests = [{ | |
}, { | ||
// Setting href to non-null non-string coerces to string | ||
url: 'google', | ||
set: {href: undefined}, | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
petkaantonov
Author
Owner
|
||
set: {href: 0}, | ||
test: { | ||
path: 'undefined', | ||
href: 'undefined' | ||
path: '0', | ||
href: '0' | ||
} | ||
}, { | ||
// Setting port is reflected in host | ||
|
@@ -180,8 +180,8 @@ const accessorTests = [{ | |
url: 'http://www.google.com', | ||
set: {search: ''}, | ||
test: { | ||
search: '?', | ||
path: '/?' | ||
search: null, | ||
path: '/' | ||
} | ||
}, { | ||
|
||
|
@@ -203,10 +203,11 @@ const accessorTests = [{ | |
}, { | ||
|
||
// Empty hash is ok | ||
url: 'http://www.google.com', | ||
url: 'http://www.google.com#hash', | ||
set: {hash: ''}, | ||
test: { | ||
hash: '#' | ||
hash: null, | ||
href: 'http://www.google.com/' | ||
} | ||
}, { | ||
|
||
|
@@ -252,7 +253,8 @@ const accessorTests = [{ | |
url: 'http://www.google.com', | ||
set: {pathname: ''}, | ||
test: { | ||
pathname: '/' | ||
pathname: null, | ||
href: 'http://www.google.com' | ||
} | ||
}, { | ||
// Null path is ok | ||
|
@@ -290,11 +292,12 @@ const accessorTests = [{ | |
protocol: null | ||
} | ||
}, { | ||
// Empty protocol is invalid | ||
// Empty protocol is ok | ||
url: 'http://www.google.com/path', | ||
set: {protocol: ''}, | ||
test: { | ||
protocol: 'http:' | ||
protocol: null, | ||
href: '//www.google.com/path' | ||
} | ||
}, { | ||
// Set query to an object | ||
|
@@ -327,9 +330,9 @@ const accessorTests = [{ | |
url: 'http://www.google.com/path?key=value', | ||
set: {path: '?key2=value2'}, | ||
test: { | ||
pathname: '/', | ||
pathname: null, | ||
search: '?key2=value2', | ||
href: 'http://www.google.com/?key2=value2' | ||
href: 'http://www.google.com?key2=value2' | ||
} | ||
}, { | ||
// path is reflected in search and pathname 3 | ||
|
@@ -349,6 +352,38 @@ const accessorTests = [{ | |
search: null, | ||
href: 'http://www.google.com' | ||
} | ||
}, { | ||
// setting hash to '' removes any hash | ||
url: 'http://www.google.com/#hash', | ||
set: {hash: ''}, | ||
test: { | ||
hash: null, | ||
href: 'http://www.google.com/' | ||
} | ||
}, { | ||
// setting hash to '#' removes any hash | ||
url: 'http://www.google.com/#hash', | ||
set: {hash: '#'}, | ||
test: { | ||
hash: null, | ||
href: 'http://www.google.com/' | ||
} | ||
}, { | ||
// setting search to '' removes any search | ||
url: 'http://www.google.com/?search', | ||
set: {search: ''}, | ||
test: { | ||
search: null, | ||
href: 'http://www.google.com/' | ||
} | ||
}, { | ||
// setting search to '?' removes any search | ||
url: 'http://www.google.com/?search', | ||
set: {search: '?'}, | ||
test: { | ||
search: null, | ||
href: 'http://www.google.com/' | ||
} | ||
} | ||
|
||
]; | ||
|
Does that mean there is no longer a test for undefined?