From 19c77118930147b7556fd6cb6fa3e18b0621e5fb Mon Sep 17 00:00:00 2001 From: Timothy Gu Date: Wed, 5 Apr 2023 12:10:25 -0700 Subject: [PATCH] redo logic for setURLSearchParams --- lib/internal/url.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) 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); } } }