Closed akindyakov closed 2 years ago
This has nothing to do specifically with this package. It's either a TS config issue or a Firefox issue.
This has nothing to do specifically with this package. It's either a TS config issue or a Firefox issue
Thanks for the update!
Do you think it doesn't make sense to use .forEach
instead? It would be more transferable and even cheaper for URLs with many query params -
O(n)
, where n
is a number query parameters. Same as before.O(k)
, where k
is a number of query parameters to delete. k ≪ n
. Now it's O(n)
. I can make a PR to fix it. It can be something like this:
if (Array.isArray(removeQueryParameters)) {
const keysToDelete: string[] = []
urlObject.searchParams.forEach((_value: string, key: string) => {
if (testParameter(key, removeQueryParameters)) {
keysToDelete.push(key)
}
})
keysToDelete.forEach((key: string) => urlObject.searchParams.delete(key))
}
What do you think @sindresorhus ?
Do you think it doesn't make sense to use .forEach instead?
I'm not interested in using .forEach
. I prefer for-of
.
Sure, thanks for the information then!
The option
removeQueryParameters
ofnormalizeUrl
with a list ofRegExp
s raises an error of "Error: o.searchParams.keys() is not iterable" only in Firefox content scripts.I compile code from TypeScript, the code snipet with usage of
normalizeUrl
is following:7.0.3
tsconfig.compilerOptions
:lib
:["ES2020","dom","dom.iterable"]
target
:es6
module
:ES2020
moduleResolution
:node
allowJs
:true
Update: if rewrite related code to use
urlObject.searchParams.forEach
it works just fine.