diff --git a/packages/next/next-server/lib/router/utils/route-regex.ts b/packages/next/next-server/lib/router/utils/route-regex.ts index b0f74bef7480a..be5c3865e2da7 100644 --- a/packages/next/next-server/lib/router/utils/route-regex.ts +++ b/packages/next/next-server/lib/router/utils/route-regex.ts @@ -107,7 +107,7 @@ export function getRouteRegex( .join('') return { - re: new RegExp(`^${parameterizedRoute}(?:/)?$`, 'i'), + re: new RegExp(`^${parameterizedRoute}(?:/)?$`), groups, routeKeys, namedRegex: `^${namedParameterizedRoute}(?:/)?$`, @@ -115,7 +115,7 @@ export function getRouteRegex( } return { - re: new RegExp(`^${parameterizedRoute}(?:/)?$`, 'i'), + re: new RegExp(`^${parameterizedRoute}(?:/)?$`), groups, } } diff --git a/test/integration/client-navigation/pages/dynamic/[slug]/route.js b/test/integration/client-navigation/pages/dynamic/[slug]/route.js new file mode 100644 index 0000000000000..0f1da367eac78 --- /dev/null +++ b/test/integration/client-navigation/pages/dynamic/[slug]/route.js @@ -0,0 +1,13 @@ +import React from 'react' + +export default class DynamicRoute extends React.Component { + static async getInitialProps({ query = { slug: 'default' } }) { + return { + query, + } + } + + render() { + return
{this.props.query.slug}
+ } +} diff --git a/test/integration/client-navigation/test/index.test.js b/test/integration/client-navigation/test/index.test.js index 482d3d5a9cee5..12d3cf648e93f 100644 --- a/test/integration/client-navigation/test/index.test.js +++ b/test/integration/client-navigation/test/index.test.js @@ -43,6 +43,7 @@ describe('Client Navigation', () => { '/url-prop-override', '/dynamic/ssr', + '/dynamic/[slug]/route', '/nav', '/nav/about', @@ -1002,6 +1003,27 @@ describe('Client Navigation', () => { await browser.close() }) + it('should get url dynamic param', async () => { + const browser = await webdriver( + context.appPort, + '/dynamic/dynamic-part/route' + ) + expect(await browser.elementByCss('p').text()).toBe('dynamic-part') + await browser.close() + }) + + it('should 404 on wrong casing of url dynamic param', async () => { + const browser = await webdriver( + context.appPort, + '/dynamic/dynamic-part/RoUtE' + ) + expect(await browser.elementByCss('h1').text()).toBe('404') + expect(await browser.elementByCss('h2').text()).toBe( + 'This page could not be found.' + ) + await browser.close() + }) + it('should not 404 for