Skip to content

Commit 19c7711

Browse files
committed
redo logic for setURLSearchParams
1 parent 37e795b commit 19c7711

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

lib/internal/url.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ class URLContext {
169169

170170
let setURLSearchParamsContext;
171171
let getURLSearchParamsList;
172-
let setURLSearchParamsList;
172+
let setURLSearchParams;
173173

174174
class URLSearchParamsIterator {
175175
#target;
@@ -277,8 +277,12 @@ class URLSearchParams {
277277
obj.#context = ctx;
278278
};
279279
getURLSearchParamsList = (obj) => obj.#searchParams;
280-
setURLSearchParamsList = (obj, list) => {
281-
obj.#searchParams = list;
280+
setURLSearchParams = (obj, query) => {
281+
if (query === undefined) {
282+
obj.#searchParams = [];
283+
} else {
284+
obj.#searchParams = parseParams(query);
285+
}
282286
};
283287
}
284288

@@ -770,9 +774,9 @@ class URL {
770774

771775
if (this.#searchParams) {
772776
if (this.#context.hasSearch) {
773-
setURLSearchParamsList(this.#searchParams, parseParams(this.search));
777+
setURLSearchParams(this.#searchParams, this.search);
774778
} else {
775-
setURLSearchParamsList(this.#searchParams, []);
779+
setURLSearchParams(this.#searchParams, undefined);
776780
}
777781
}
778782
}

0 commit comments

Comments
 (0)