diff --git a/packages/next/src/client/components/navigation.test.ts b/packages/next/src/client/components/navigation.test.ts new file mode 100644 index 0000000000000..05569915dad7f --- /dev/null +++ b/packages/next/src/client/components/navigation.test.ts @@ -0,0 +1,9 @@ +import { ReadonlyURLSearchParams } from './navigation' + +describe('next/navigation', () => { + it('should be able to construct URLSearchParams from ReadonlyURLSearchParams', () => { + const searchParams = new URLSearchParams('?foo=test&bar=test') + const readonlySearchParams = new ReadonlyURLSearchParams(searchParams) + expect(() => new URLSearchParams(readonlySearchParams)).not.toThrow() + }) +}) diff --git a/packages/next/src/client/components/navigation.ts b/packages/next/src/client/components/navigation.ts index 349927f905a9c..523870d9908ec 100644 --- a/packages/next/src/client/components/navigation.ts +++ b/packages/next/src/client/components/navigation.ts @@ -33,6 +33,7 @@ export class ReadonlyURLSearchParams { keys: URLSearchParams['keys'] values: URLSearchParams['values'] toString: URLSearchParams['toString'] + size: any | URLSearchParams['size'] constructor(urlSearchParams: URLSearchParams) { this[INTERNAL_URLSEARCHPARAMS_INSTANCE] = urlSearchParams @@ -45,6 +46,7 @@ export class ReadonlyURLSearchParams { this.keys = urlSearchParams.keys.bind(urlSearchParams) this.values = urlSearchParams.values.bind(urlSearchParams) this.toString = urlSearchParams.toString.bind(urlSearchParams) + this.size = urlSearchParams.size } [Symbol.iterator]() { return this[INTERNAL_URLSEARCHPARAMS_INSTANCE][Symbol.iterator]()