Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
'+' is considered now considered a valid host character
  • Loading branch information
petkaantonov committed Jan 8, 2015
1 parent 8a0bd4e commit 1f34819
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 14 deletions.
8 changes: 6 additions & 2 deletions src/urlparser.js
Original file line number Diff line number Diff line change
Expand Up @@ -602,8 +602,12 @@ function Url$_parseHost(str, start, end, slashesDenoteHost) {
else if (0x41 /*'A'*/ <= ch && ch <= 0x5A /*'Z'*/) {
doLowerCase = true;
}
else if (!(ch === 0x2D /*'-'*/ || ch === 0x5F /*'_'*/ ||
(0x30 /*'0'*/ <= ch && ch <= 0x39 /*'9'*/))) {
//Valid characters other than ASCII letters -, _, +, 0-9
else if (!(ch === 0x2D /*'-'*/ ||
ch === 0x5F /*'_'*/ ||
ch === 0x2B /*'+'*/ ||
(0x30 /*'0'*/ <= ch && ch <= 0x39 /*'9'*/))
) {
if (hostEndingCharacters[ch] === 0 &&
this._noPrependSlashHostEnders[ch] === 0) {
this._prependSlash = true;
Expand Down
36 changes: 24 additions & 12 deletions test/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,32 +173,44 @@ var parseTests = {
'path': '/Y'
},

// + not an invalid host character
// per https://url.spec.whatwg.org/#host-parsing
'http://x.y.com+a/b/c' : {
'href': 'http://x.y.com+a/b/c',
'protocol': 'http:',
'slashes': true,
'host': 'x.y.com+a',
'hostname': 'x.y.com+a',
'pathname': '/b/c',
'path': '/b/c'
},

// an unexpected invalid char in the hostname.
'HtTp://x.y.cOm*a/b/c?d=e#f g<h>i' : {
'href': 'http://x.y.com/*a/b/c?d=e#f%20g%3Ch%3Ei',
'HtTp://x.y.cOm;a/b/c?d=e#f g<h>i' : {
'href': 'http://x.y.com/;a/b/c?d=e#f%20g%3Ch%3Ei',
'protocol': 'http:',
'slashes': true,
'host': 'x.y.com',
'hostname': 'x.y.com',
'pathname': '/*a/b/c',
'pathname': ';a/b/c',
'search': '?d=e',
'query': 'd=e',
'hash': '#f%20g%3Ch%3Ei',
'path': '/*a/b/c?d=e'
'path': ';a/b/c?d=e'
},

// make sure that we don't accidentally lcast the path parts.
'HtTp://x.y.cOm*A/b/c?d=e#f g<h>i' : {
'href': 'http://x.y.com/*A/b/c?d=e#f%20g%3Ch%3Ei',
'HtTp://x.y.cOm;A/b/c?d=e#f g<h>i' : {
'href': 'http://x.y.com/;A/b/c?d=e#f%20g%3Ch%3Ei',
'protocol': 'http:',
'slashes': true,
'host': 'x.y.com',
'hostname': 'x.y.com',
'pathname': '/*A/b/c',
'pathname': ';A/b/c',
'search': '?d=e',
'query': 'd=e',
'hash': '#f%20g%3Ch%3Ei',
'path': '/*A/b/c?d=e'
'path': ';A/b/c?d=e'
},

'http://x...y...#p': {
Expand Down Expand Up @@ -513,17 +525,17 @@ var parseTests = {
'path': '/'
},

'http://www.Äffchen.cOm*A/b/c?d=e#f g<h>i' : {
'href': 'http://www.xn--ffchen-9ta.com/*A/b/c?d=e#f%20g%3Ch%3Ei',
'http://www.Äffchen.cOm;A/b/c?d=e#f g<h>i' : {
'href': 'http://www.xn--ffchen-9ta.com/;A/b/c?d=e#f%20g%3Ch%3Ei',
'protocol': 'http:',
'slashes': true,
'host': 'www.xn--ffchen-9ta.com',
'hostname': 'www.xn--ffchen-9ta.com',
'pathname': '/*A/b/c',
'pathname': ';A/b/c',
'search': '?d=e',
'query': 'd=e',
'hash': '#f%20g%3Ch%3Ei',
'path': '/*A/b/c?d=e'
'path': ';A/b/c?d=e'
},

'http://SÉLIER.COM/' : {
Expand Down

0 comments on commit 1f34819

Please sign in to comment.