summaryrefslogtreecommitdiff
path: root/js/url_search_params.ts
diff options
context:
space:
mode:
Diffstat (limited to 'js/url_search_params.ts')
-rw-r--r--js/url_search_params.ts17
1 files changed, 17 insertions, 0 deletions
diff --git a/js/url_search_params.ts b/js/url_search_params.ts
index 13b272476..1d9aa43b3 100644
--- a/js/url_search_params.ts
+++ b/js/url_search_params.ts
@@ -1,8 +1,10 @@
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
+import { URL } from "./url";
import { requiredArguments } from "./util";
export class URLSearchParams {
private params: Array<[string, string]> = [];
+ private url: URL | null = null;
constructor(init: string | string[][] | Record<string, string> = "") {
if (typeof init === "string") {
@@ -30,6 +32,20 @@ export class URLSearchParams {
}
}
+ private updateSteps(): void {
+ if (this.url === null) {
+ return;
+ }
+
+ let query: string | null = this.toString();
+ if (query === "") {
+ query = null;
+ }
+
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
+ (this.url as any)._parts.query = query;
+ }
+
/** Appends a specified key/value pair as a new search parameter.
*
* searchParams.append('name', 'first');
@@ -56,6 +72,7 @@ export class URLSearchParams {
i++;
}
}
+ this.updateSteps();
}
/** Returns all the values associated with a given search parameter