Skip to content

Commit 6092aaf

Browse files
committed
short circuit
1 parent ada2e4b commit 6092aaf

File tree

1 file changed

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

1 file changed

+2
-4
lines changed

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -464,13 +464,11 @@ export function normalizeLocationHeader(
464464
const locationURL = new URL(location);
465465
const origin = new URL(baseUrl).origin;
466466

467-
// Redirects from the middleware do not encode the query parameters
468467
let search = locationURL.search;
469468
// If encodeQuery is true, we need to encode the query parameters
470-
// This is used for redirects from Next config
471469
// We could have used URLSearchParams, but that doesn't match what Next does.
472-
if (encodeQuery) {
473-
search = search ? `?${stringifyQs(parseQs(search.slice(1)))}` : "";
470+
if (encodeQuery && search) {
471+
search = `?${stringifyQs(parseQs(search.slice(1)))}`;
474472
}
475473
const href = `${locationURL.origin}${locationURL.pathname}${search}${locationURL.hash}`;
476474
// The URL is relative if the origin is the same as the base URL's origin

0 commit comments

Comments
 (0)