| Index: lib/url.js |
| =================================================================== |
| --- a/lib/url.js |
| +++ b/lib/url.js |
| @@ -20,25 +20,6 @@ |
| "use strict"; |
| const {getDomain} = require("./tldjs"); |
| -const punycode = require("./punycode"); |
| - |
| -let getDecodedHostname = |
| -/** |
| - * Gets the IDN-decoded hostname from a URL object. |
| - * |
| - * @param {URL} url |
| - * @return {string} |
| - * @static |
| - */ |
| -exports.getDecodedHostname = url => |
| -{ |
| - let {hostname} = url; |
| - |
| - if (hostname.indexOf("xn--") == -1) |
| - return hostname; |
| - |
| - return punycode.toUnicode(hostname); |
| -}; |
| /** |
| * Gets the IDN-decoded hostname from the URL of a frame. |
| @@ -53,37 +34,12 @@ |
| { |
| for (; frame; frame = frame.parent) |
| { |
| - let hostname = getDecodedHostname(frame.url); |
| + let hostname = frame.url.hostname; |
| if (hostname) |
| return hostname; |
| } |
| - return originUrl ? getDecodedHostname(originUrl) : ""; |
| -}; |
| - |
| -/** |
| - * 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} |
| - */ |
| -exports.stringifyURL = url => |
| -{ |
| - let {protocol, href} = url; |
| - |
| - if (protocol == "http:" || protocol == "https:") |
| - { |
| - let {hostname} = url; |
| - 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; |
| + return originUrl ? originUrl.hostname : ""; |
| }; |
| function isDomain(hostname) |
| @@ -106,7 +62,7 @@ |
| */ |
| exports.isThirdParty = (url, documentHost) => |
| { |
| - let requestHost = getDecodedHostname(url).replace(/\.+$/, ""); |
| + let requestHost = url.hostname.replace(/\.+$/, ""); |
| documentHost = documentHost.replace(/\.+$/, ""); |
| if (requestHost == documentHost) |