From 3a76a8a7ce4601c48434e786239de2b4547f0c0a Mon Sep 17 00:00:00 2001 From: Javi Velasco Date: Mon, 13 Dec 2021 18:54:17 +0100 Subject: [PATCH] Temporary disable URL extension for NextURL --- packages/next/server/web/next-url.ts | 9 +++++---- test/unit/web-runtime/next-url.test.ts | 3 ++- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/packages/next/server/web/next-url.ts b/packages/next/server/web/next-url.ts index e1287b45dc2948e..8ee57ff66a6cbcf 100644 --- a/packages/next/server/web/next-url.ts +++ b/packages/next/server/web/next-url.ts @@ -14,7 +14,7 @@ interface Options { const Internal = Symbol('NextURLInternal') -export class NextURL extends URL { +export class NextURL { [Internal]: { url: URL options: Options @@ -36,12 +36,13 @@ export class NextURL extends URL { baseOrOpts?: string | URL | Options, opts?: Options ) { - super('http://127.0.0.1') // This works as a placeholder - let base: undefined | string | URL let options: Options - if (baseOrOpts instanceof URL || typeof baseOrOpts === 'string') { + if ( + (typeof baseOrOpts === 'object' && 'pathname' in baseOrOpts) || + typeof baseOrOpts === 'string' + ) { base = baseOrOpts options = opts || {} } else { diff --git a/test/unit/web-runtime/next-url.test.ts b/test/unit/web-runtime/next-url.test.ts index 7acbdd25b2be0a0..e3914a938e92013 100644 --- a/test/unit/web-runtime/next-url.test.ts +++ b/test/unit/web-runtime/next-url.test.ts @@ -1,7 +1,8 @@ /* eslint-env jest */ import { NextURL } from 'next/dist/server/web/next-url' -it('has the right shape and prototype', () => { +// TODO Make NextURL extend URL +it.skip('has the right shape and prototype', () => { const parsed = new NextURL('/about?param1=value1', 'http://127.0.0.1') expect(parsed).toBeInstanceOf(URL) })