Skip to content

Commit

Permalink
redo logic for setURLSearchParams
Browse files Browse the repository at this point in the history
  • Loading branch information
TimothyGu committed Apr 5, 2023
1 parent 37e795b commit 19c7711
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions lib/internal/url.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ class URLContext {

let setURLSearchParamsContext;
let getURLSearchParamsList;
let setURLSearchParamsList;
let setURLSearchParams;

class URLSearchParamsIterator {
#target;
Expand Down Expand Up @@ -277,8 +277,12 @@ class URLSearchParams {
obj.#context = ctx;
};
getURLSearchParamsList = (obj) => obj.#searchParams;
setURLSearchParamsList = (obj, list) => {
obj.#searchParams = list;
setURLSearchParams = (obj, query) => {
if (query === undefined) {
obj.#searchParams = [];
} else {
obj.#searchParams = parseParams(query);
}
};
}

Expand Down Expand Up @@ -770,9 +774,9 @@ class URL {

if (this.#searchParams) {
if (this.#context.hasSearch) {
setURLSearchParamsList(this.#searchParams, parseParams(this.search));
setURLSearchParams(this.#searchParams, this.search);
} else {
setURLSearchParamsList(this.#searchParams, []);
setURLSearchParams(this.#searchParams, undefined);
}
}
}
Expand Down

0 comments on commit 19c7711

Please sign in to comment.