From dad3299852595c286ac5977516fa670892b72689 Mon Sep 17 00:00:00 2001 From: Jan Potoms <2109932+Janpot@users.noreply.github.com> Date: Thu, 16 Jul 2020 22:44:45 +0200 Subject: [PATCH 1/3] Improve query conversion logic (#15236) `URLSearchParams` has a `forEach` method. this should simplify and shorten the logic. Perhaps it will even phix https://github.com/vercel/next.js/issues/15232 --- .../next-server/lib/router/utils/search-params-to-url-query.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/next/next-server/lib/router/utils/search-params-to-url-query.ts b/packages/next/next-server/lib/router/utils/search-params-to-url-query.ts index 72a759f3de04f..39a6b3120894d 100644 --- a/packages/next/next-server/lib/router/utils/search-params-to-url-query.ts +++ b/packages/next/next-server/lib/router/utils/search-params-to-url-query.ts @@ -4,7 +4,7 @@ export function searchParamsToUrlQuery( searchParams: URLSearchParams ): ParsedUrlQuery { const query: ParsedUrlQuery = {} - Array.from(searchParams.entries()).forEach(([key, value]) => { + searchParams.forEach((value, key) => { if (typeof query[key] === 'undefined') { query[key] = value } else if (Array.isArray(query[key])) { From bd9fc12f92915067e441b221a3652542687a7569 Mon Sep 17 00:00:00 2001 From: Tim Neutkens Date: Fri, 17 Jul 2020 00:29:34 +0200 Subject: [PATCH 2/3] Fix ky-universal-polyfill in webpack 5 (#15227) Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> Co-authored-by: Joe Haddad --- package.json | 1 + yarn.lock | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/package.json b/package.json index 16e9420986a95..37a89e189f5b6 100644 --- a/package.json +++ b/package.json @@ -122,6 +122,7 @@ "tree-kill": "1.2.1", "typescript": "3.8.3", "wait-port": "0.2.2", + "web-streams-polyfill": "2.1.1", "webpack-bundle-analyzer": "3.6.1", "worker-loader": "2.0.0" }, diff --git a/yarn.lock b/yarn.lock index dac6f9060ec0a..5faf1bee29442 100644 --- a/yarn.lock +++ b/yarn.lock @@ -16016,6 +16016,11 @@ wcwidth@^1.0.0, wcwidth@^1.0.1: dependencies: defaults "^1.0.3" +web-streams-polyfill@2.1.1: + version "2.1.1" + resolved "https://registry.yarnpkg.com/web-streams-polyfill/-/web-streams-polyfill-2.1.1.tgz#2c82b6193849ccb9efaa267772c28260ef68d6d2" + integrity sha512-dlNpL2aab3g8CKfGz6rl8FNmGaRWLLn2g/DtSc9IjB30mEdE6XxzPfPSig5BwGSzI+oLxHyETrQGKjrVVhbLCg== + web-vitals@0.2.1: version "0.2.1" resolved "https://registry.yarnpkg.com/web-vitals/-/web-vitals-0.2.1.tgz#60782fa690243fe35613759a0c26431f57ba7b2d" From e56a6add8de788baa6bee2865c469e6f7bdc1fb9 Mon Sep 17 00:00:00 2001 From: Jan Potoms <2109932+Janpot@users.noreply.github.com> Date: Fri, 17 Jul 2020 00:47:46 +0200 Subject: [PATCH 3/3] Add test for query param bug #15233 (#15238) Fixes https://github.com/vercel/next.js/issues/15233 --- test/integration/link-with-encoding/pages/index.js | 4 ++++ test/integration/link-with-encoding/pages/query.js | 7 +++++++ .../link-with-encoding/test/index.test.js | 14 ++++++++++++++ 3 files changed, 25 insertions(+) create mode 100644 test/integration/link-with-encoding/pages/query.js diff --git a/test/integration/link-with-encoding/pages/index.js b/test/integration/link-with-encoding/pages/index.js index 6534196c286eb..198f89935a489 100644 --- a/test/integration/link-with-encoding/pages/index.js +++ b/test/integration/link-with-encoding/pages/index.js @@ -30,6 +30,10 @@ const Home = () => ( > Single: : +
+ + Url query param + ) diff --git a/test/integration/link-with-encoding/pages/query.js b/test/integration/link-with-encoding/pages/query.js new file mode 100644 index 0000000000000..69b7a26e690aa --- /dev/null +++ b/test/integration/link-with-encoding/pages/query.js @@ -0,0 +1,7 @@ +export function getServerSideProps({ query }) { + return { props: query } +} + +export default function Single(props) { + return
{JSON.stringify(props)}
+} diff --git a/test/integration/link-with-encoding/test/index.test.js b/test/integration/link-with-encoding/test/index.test.js index 63bd57d2c4f60..5d777f4de166c 100644 --- a/test/integration/link-with-encoding/test/index.test.js +++ b/test/integration/link-with-encoding/test/index.test.js @@ -295,5 +295,19 @@ describe('Link Component with Encoding', () => { await browser.close() } }) + + it('should have correct parsing of url query params', async () => { + const browser = await webdriver(appPort, '/') + try { + await browser.waitForElementByCss('#url-param').click() + const content = await browser + .waitForElementByCss('#query-content') + .text() + const query = JSON.parse(content) + expect(query).toHaveProperty('id', 'http://example.com/') + } finally { + await browser.close() + } + }) }) })