aboutsummaryrefslogtreecommitdiff
path: root/packages/taler-util
diff options
context:
space:
mode:
authorFlorian Dold <florian@dold.me>2022-11-12 19:18:55 +0100
committerFlorian Dold <florian@dold.me>2022-11-12 19:18:55 +0100
commitf09a502fe7f1cb7583265c91ff95bbb4740720b0 (patch)
tree3e89028729621ca34731160de7db19b86f4a26e0 /packages/taler-util
parent233a354b4728b5efc76d19a530ad85a3a3e2a3d2 (diff)
fix URLSearchParams and HTTP typing issue
Diffstat (limited to 'packages/taler-util')
-rw-r--r--packages/taler-util/src/url.ts7
-rw-r--r--packages/taler-util/src/whatwg-url.ts20
2 files changed, 21 insertions, 6 deletions
diff --git a/packages/taler-util/src/url.ts b/packages/taler-util/src/url.ts
index eb7248b7b..149997f3f 100644
--- a/packages/taler-util/src/url.ts
+++ b/packages/taler-util/src/url.ts
@@ -82,9 +82,12 @@ export interface URLCtor {
delete Object.prototype.__magic__;
})();
+// Use native or pure JS URL implementation?
+const useOwnUrlImp = true;
+
// @ts-ignore
let _URL = globalThis.URL;
-if (!_URL) {
+if (useOwnUrlImp || !_URL) {
// @ts-ignore
globalThis.URL = _URL = URLImpl;
// @ts-ignore
@@ -96,7 +99,7 @@ export const URL: URLCtor = _URL;
// @ts-ignore
let _URLSearchParams = globalThis.URLSearchParams;
-if (!_URLSearchParams) {
+if (useOwnUrlImp || !_URLSearchParams) {
// @ts-ignore
globalThis.URLSearchParams = URLSearchParamsImpl;
// @ts-ignore
diff --git a/packages/taler-util/src/whatwg-url.ts b/packages/taler-util/src/whatwg-url.ts
index a0fe55d8f..991528ae6 100644
--- a/packages/taler-util/src/whatwg-url.ts
+++ b/packages/taler-util/src/whatwg-url.ts
@@ -347,8 +347,7 @@ function isASCIIHex(c: number) {
export class URLSearchParamsImpl {
_list: any[];
_url: any;
- constructor(constructorArgs: any[], { doNotStripQMark = false }: any) {
- let init = constructorArgs[0];
+ constructor(init: any, { doNotStripQMark = false }: any = {}) {
this._list = [];
this._url = null;
@@ -425,6 +424,19 @@ export class URLSearchParamsImpl {
return output;
}
+ forEach(
+ callbackfn: (
+ value: string,
+ key: string,
+ parent: URLSearchParamsImpl,
+ ) => void,
+ thisArg?: any,
+ ): void {
+ for (const tuple of this._list) {
+ callbackfn.call(thisArg, tuple[1], tuple[0], this);
+ }
+ }
+
has(name: string) {
for (const tuple of this._list) {
if (tuple[0] === name) {
@@ -1916,7 +1928,7 @@ export class URLImpl {
// We cannot invoke the "new URLSearchParams object" algorithm without going through the constructor, which strips
// question mark by default. Therefore the doNotStripQMark hack is used.
- this._query = new URLSearchParamsImpl([query], {
+ this._query = new URLSearchParamsImpl(query, {
doNotStripQMark: true,
});
this._query._url = this;
@@ -2104,4 +2116,4 @@ export class URLImpl {
// FIXME: type!
_url: any;
_query: any;
-} \ No newline at end of file
+}