Index: lib/domain.js |
=================================================================== |
--- a/lib/domain.js |
+++ b/lib/domain.js |
@@ -109,24 +109,25 @@ |
return slices[cutoff]; |
} |
exports.getDomain = getDomain; |
/** |
* Checks whether a request's origin is different from its document's origin. |
* |
- * @param {URL} url The request URL. |
+ * @param {URL|string} url The request URL. |
Sebastian Noack
2019/02/05 04:32:53
Do we even still need to support the case where an
Manish Jethani
2019/02/05 05:07:28
Actually the default is a URL object now, which is
Sebastian Noack
2019/02/05 05:21:16
So why did you add support for passing in strings
Manish Jethani
2019/02/05 05:42:23
It's there for backwards compatibility with (1) li
Sebastian Noack
2019/02/05 05:54:45
I don't get it, you can just make the unit tsts cr
|
* @param {string} documentHostname The IDNA-encoded hostname of the document. |
* |
* @returns {boolean} |
*/ |
function isThirdParty(url, documentHostname) |
{ |
- let requestHostname = url.hostname; |
+ let requestHostname = typeof url == "string" ? new URL(url).hostname : |
+ url.hostname; |
if (requestHostname[requestHostname.length - 1] == ".") |
requestHostname = requestHostname.replace(/\.+$/, ""); |
if (documentHostname[documentHostname.length - 1] == ".") |
documentHostname = documentHostname.replace(/\.+$/, ""); |
if (requestHostname == documentHostname) |