Skip to content

Commit

Permalink
url: Add support for RFC 3490 separators
Browse files Browse the repository at this point in the history
There is no need to split the host by hand in `url.js` – Punycode.js
takes care of it anyway. This not only simplifies the code, but also
adds support for RFC 3490 separators (i.e. not just U+002E, but U+3002,
U+FF0E, and U+FF61 as well).

Closes nodejs#6055.

Reviewed-By: Fedor Indutny <[email protected]>
  • Loading branch information
mathiasbynens authored and indutny committed Aug 27, 2014
1 parent 0f29561 commit b869797
Showing 1 changed file with 5 additions and 12 deletions.
17 changes: 5 additions & 12 deletions lib/url.js
Original file line number Diff line number Diff line change
Expand Up @@ -256,18 +256,11 @@ Url.prototype.parse = function(url, parseQueryString, slashesDenoteHost) {
}

if (!ipv6Hostname) {
// IDNA Support: Returns a puny coded representation of "domain".
// It only converts the part of the domain name that
// has non ASCII characters. I.e. it dosent matter if
// you call it with a domain that already is in ASCII.
var domainArray = this.hostname.split('.');
var newOut = [];
for (var i = 0; i < domainArray.length; ++i) {
var s = domainArray[i];
newOut.push(s.match(/[^A-Za-z0-9_-]/) ?
'xn--' + punycode.encode(s) : s);
}
this.hostname = newOut.join('.');
// IDNA Support: Returns a punycoded representation of "domain".
// It only converts parts of the domain name that
// have non-ASCII characters, i.e. it doesn't matter if
// you call it with a domain that already is ASCII-only.
this.hostname = punycode.toASCII(this.hostname);
}

var p = this.port ? ':' + this.port : '';
Expand Down

0 comments on commit b869797

Please sign in to comment.