Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: lib/url.js

Issue 29772555: Issue 6647 - Stop converting domains from punycode to unicode (Closed)
Patch Set: Created May 6, 2018, 2:42 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
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)
« lib/options.js ('K') | « lib/requestBlocker.js ('k') | lib/whitelisting.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld