diff options
author | Mathias Bynens <mathias@qiwi.be> | 2014-08-04 12:44:06 +0200 |
---|---|---|
committer | Fedor Indutny <fedor@indutny.com> | 2014-08-27 14:36:04 +0400 |
commit | b869797a2de4c806382975f4114aac8841edcb15 (patch) | |
tree | b6333b6e963c017809e101f3f72f5504550d6ff0 /lib/url.js | |
parent | 0f2956192c51abc6fc8311102b004f1e975e157f (diff) | |
download | android-node-v8-b869797a2de4c806382975f4114aac8841edcb15.tar.gz android-node-v8-b869797a2de4c806382975f4114aac8841edcb15.tar.bz2 android-node-v8-b869797a2de4c806382975f4114aac8841edcb15.zip |
url: Add support for RFC 3490 separators
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 #6055.
Reviewed-By: Fedor Indutny <fedor@indutny.com>
Diffstat (limited to 'lib/url.js')
-rw-r--r-- | lib/url.js | 17 |
1 files changed, 5 insertions, 12 deletions
diff --git a/lib/url.js b/lib/url.js index c13f74b5dd..d5948e450b 100644 --- a/lib/url.js +++ b/lib/url.js @@ -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 : ''; |