Skip to content

Commit

Permalink
Merge branch 'canary' into canary
Browse files Browse the repository at this point in the history
  • Loading branch information
kodiakhq[bot] authored Jul 16, 2020
2 parents 6044aa0 + e56a6ad commit b327315
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 1 deletion.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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])) {
Expand Down
4 changes: 4 additions & 0 deletions test/integration/link-with-encoding/pages/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ const Home = () => (
>
<a id="single-colon">Single: :</a>
</Link>
<br />
<Link href="/query?id=http://example.com/">
<a id="url-param">Url query param</a>
</Link>
</div>
)

Expand Down
7 changes: 7 additions & 0 deletions test/integration/link-with-encoding/pages/query.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export function getServerSideProps({ query }) {
return { props: query }
}

export default function Single(props) {
return <pre id="query-content">{JSON.stringify(props)}</pre>
}
14 changes: 14 additions & 0 deletions test/integration/link-with-encoding/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
})
})
})
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -16016,6 +16016,11 @@ wcwidth@^1.0.0, wcwidth@^1.0.1:
dependencies:
defaults "^1.0.3"

[email protected]:
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==

[email protected]:
version "0.2.1"
resolved "https://registry.yarnpkg.com/web-vitals/-/web-vitals-0.2.1.tgz#60782fa690243fe35613759a0c26431f57ba7b2d"
Expand Down

0 comments on commit b327315

Please sign in to comment.