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

Unified Diff: lib/domain.js

Issue 29998564: Issue 7260 - Internalize third-party request check in matcher (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Patch Set: Created Feb. 5, 2019, 4:04 a.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
« no previous file with comments | « no previous file | lib/matcher.js » ('j') | lib/matcher.js » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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)
« no previous file with comments | « no previous file | lib/matcher.js » ('j') | lib/matcher.js » ('J')

Powered by Google App Engine
This is Rietveld