Skip to content

Commit 0d9927d

Browse files
Decode query string for URLSearchParams
1 parent e2ba2e8 commit 0d9927d

File tree

1 file changed

+5
-2
lines changed
  • packages/open-next/src/core/routing

1 file changed

+5
-2
lines changed

packages/open-next/src/core/routing/util.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,12 +98,15 @@ export function convertRes(res: OpenNextNodeResponse): InternalResult {
9898
* @__PURE__
9999
*/
100100
export function convertToQueryString(query: Record<string, string | string[]>) {
101+
// URLSearchParams is a a representation of the PARSED query.
102+
// So we must decode the value before appending it to the URLSearchParams.
103+
// https://stackoverflow.com/a/45516812
101104
const urlQuery = new URLSearchParams();
102105
Object.entries(query).forEach(([key, value]) => {
103106
if (Array.isArray(value)) {
104-
value.forEach((entry) => urlQuery.append(key, entry));
107+
value.forEach((entry) => urlQuery.append(key, decodeURIComponent(entry)));
105108
} else {
106-
urlQuery.append(key, value);
109+
urlQuery.append(key, decodeURIComponent(value));
107110
}
108111
});
109112
const queryString = urlQuery.toString();

0 commit comments

Comments
 (0)