| Index: lib/url.js |
| =================================================================== |
| --- a/lib/url.js |
| +++ b/lib/url.js |
| @@ -85,8 +85,8 @@ |
| exports.extractHostFromFrame = extractHostFromFrame; |
| /** |
| - * Converts a URL object into a string. For HTTP(S) URLs the hash and |
| - * auth crendetials are stripped, and the hostname gets IDN-decoded. |
| + * Converts a URL object into a string. For HTTP(S) URLs |
| + * the hostname gets IDN-decoded and the hash is stripped. |
| * |
| * @param {URL} [url] |
| * @return {string} |
| @@ -94,14 +94,22 @@ |
| function stringifyURL(url) |
| { |
| let protocol = url.protocol; |
| - if (protocol != "http:" && protocol != "https:") |
| - return url.href; |
| + let href = url.href; |
| - let host = getDecodedHostname(url); |
| - if (url.port) |
| - host += ":" + url.port; |
| - return protocol + "//" + host + url.pathname + url.search; |
| + if (protocol == "http:" || protocol == "https:") |
| + { |
| + let hostname = url.hostname; |
| + if (hostname.indexOf("xn--") != -1) |
| + href = href.replace(hostname, punycode.toUnicode(hostname)); |
| + |
| + let hash = href.indexOf("#"); |
| + if (hash != -1) |
| + href = href.substr(0, hash); |
| + } |
| + |
| + return href; |
| } |
| + |
| exports.stringifyURL = stringifyURL; |
| function isDomain(hostname) |