Index: lib/url.js |
=================================================================== |
--- a/lib/url.js |
+++ b/lib/url.js |
@@ -18,7 +18,7 @@ |
window.URL = (function() |
{ |
let URL = window.URL || window.webkitURL; |
- let URLProperties = ["href", "protocol", "host", "hostname", "port", "pathname", "search"]; |
+ let URLProperties = ["href", "protocol", "host", "hostname", "pathname", "search"]; |
kzar
2015/03/02 15:04:13
Do we not need to check the port for a URL anywher
Sebastian Noack
2015/03/02 15:10:37
Not as far as I know. But feel free to double chec
Sebastian Noack
2015/03/02 15:18:21
contentPolicy.js is Firefox-specific code, also it
|
if (!URL || !URLProperties.every(prop => prop in new URL("about:blank"))) |
{ |
@@ -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) |