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); |