diff --git a/lib/internal/url.js b/lib/internal/url.js index 1222b0cf291688..f16ba9de840eb4 100644 --- a/lib/internal/url.js +++ b/lib/internal/url.js @@ -169,7 +169,7 @@ class URLContext { let setURLSearchParamsContext; let getURLSearchParamsList; -let setURLSearchParamsList; +let setURLSearchParams; class URLSearchParamsIterator { #target; @@ -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); + } }; } @@ -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); } } }