Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'lib/url.js')
-rw-r--r--lib/url.js17
1 files changed, 5 insertions, 12 deletions
diff --git a/lib/url.js b/lib/url.js
index 7d2ac4e2d00..4c0ef0102fa 100644
--- a/lib/url.js
+++ b/lib/url.js
@@ -278,18 +278,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 : '';