Skip to content

Commit

Permalink
fix searchParams dev warning
Browse files Browse the repository at this point in the history
  • Loading branch information
ztanner committed Sep 2, 2020
1 parent 0649176 commit 9bf37bf
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/next/next-server/lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,7 @@ export const urlObjectKeys = [
'protocol',
'query',
'search',
'searchParams',
'slashes',
]

Expand Down
9 changes: 9 additions & 0 deletions test/integration/dynamic-routing/pages/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
import Link from 'next/link'
import { useRouter } from 'next/router'

if (typeof window !== 'undefined') {
window.caughtWarns = []
const origWarn = window.console.warn
window.console.warn = function (...args) {
window.caughtWarns.push(args)
origWarn(...args)
}
}

const Page = () => {
return (
<div>
Expand Down
6 changes: 6 additions & 0 deletions test/integration/dynamic-routing/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,12 @@ function runTests(dev) {
expect(url).toBe('?fromHome=true')
})

it('should not have any console warnings', async () => {
const browser = await webdriver(appPort, '/')
const caughtWarns = await browser.eval(`window.caughtWarns`)
expect(caughtWarns).toEqual([])
})

it('should navigate to a dynamic page successfully', async () => {
let browser
try {
Expand Down

0 comments on commit 9bf37bf

Please sign in to comment.