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

Unified Diff: lib/content/snippets.js

Issue 30013555: Issue 7294 - Pass necessary functions to strip-fetch-query-parameter (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Patch Set: Created Feb. 21, 2019, 8:13 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/content/snippets.js
===================================================================
--- a/lib/content/snippets.js
+++ b/lib/content/snippets.js
@@ -856,25 +856,29 @@
* Strips a query string parameter from <code>fetch()</code> calls.
*
* @param {string} name The name of the parameter.
* @param {?string} [urlPattern] An optional pattern that the URL must match.
*/
function stripFetchQueryParameter(name, urlPattern = null)
{
let fetch_ = window.fetch;
+ if (typeof fetch_ != "function")
Manish Jethani 2019/02/21 08:15:43 Being defensive, just in case fetch does't exist (
+ return;
+
let urlRegExp = urlPattern ? toRegExp(urlPattern) : null;
window.fetch = function fetch(...args)
{
let [source] = args;
if (typeof source == "string" &&
(!urlRegExp || urlRegExp.test(source)))
{
let url = new URL(source);
url.searchParams.delete(name);
args[0] = url.href;
}
- return fetch_.apply(this, args);
+
+ return (() => {}).apply.call(fetch_, this, args);
Manish Jethani 2019/02/21 08:15:43 This is because you can have a function with a nul
a.giammarchi 2019/02/21 08:27:35 IMO this is super ugly and it doesn't prevent poss
Manish Jethani 2019/02/21 08:57:16 This is not about overrides but rather about the p
Manish Jethani 2019/02/21 09:00:36 Done.
};
}
-exports["strip-fetch-query-parameter"] =
- makeInjector(stripFetchQueryParameter);
+exports["strip-fetch-query-parameter"] = makeInjector(stripFetchQueryParameter,
+ toRegExp, regexEscape);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld