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: Simplify Created Feb. 21, 2019, 9 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,28 @@
* 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")
+ 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);
a.giammarchi 2019/02/21 10:26:58 cannot we just `return fetch_(...args)` after late
Manish Jethani 2019/02/21 10:35:04 I don't see why we should assume anything about th
};
}
-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