From 37bfc65638f7041c14e8135904f0939c280848f7 Mon Sep 17 00:00:00 2001 From: Jan Potoms <2109932+Janpot@users.noreply.github.com> Date: Fri, 31 Jul 2020 08:38:39 +0200 Subject: [PATCH] Fix wrong asPath on 404 (#15728) Caught this while reviewing router code for https://github.com/vercel/next.js/pull/15710 --- packages/next/client/index.js | 2 +- test/integration/basepath/test/index.test.js | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/next/client/index.js b/packages/next/client/index.js index 91a723c06738e..fc7d439a8a5f4 100644 --- a/packages/next/client/index.js +++ b/packages/next/client/index.js @@ -58,7 +58,7 @@ if ( page === '/_error' && hydrateProps && hydrateProps.pageProps && - hydrateProps.pageProps.statusCode === '404' + hydrateProps.pageProps.statusCode === 404 ) ) { asPath = delBasePath(asPath) diff --git a/test/integration/basepath/test/index.test.js b/test/integration/basepath/test/index.test.js index 2bddf06d05506..593d9b23e95e7 100644 --- a/test/integration/basepath/test/index.test.js +++ b/test/integration/basepath/test/index.test.js @@ -212,6 +212,7 @@ const runTests = (context, dev = false) => { it('should not update URL for a 404', async () => { const browser = await webdriver(context.appPort, '/missing') const pathname = await browser.eval(() => window.location.pathname) + expect(await browser.eval(() => window.next.router.asPath)).toBe('/missing') expect(pathname).toBe('/missing') })