Unverified Commit 574fe0b5 authored by Jan Potoms's avatar Jan Potoms Committed by GitHub

Make dynamic routes case-sensitive (#15444)

Fixes https://github.com/vercel/next.js/issues/15377
Closes https://github.com/vercel/next.js/pull/15394
parent f22f88fd
......@@ -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,
}
}
import React from 'react'
export default class DynamicRoute extends React.Component {
static async getInitialProps({ query = { slug: 'default' } }) {
return {
query,
}
}
render() {
return <p>{this.props.query.slug}</p>
}
}
......@@ -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 <page>/', async () => {
const browser = await webdriver(context.appPort, '/nav/about/')
const text = await browser.elementByCss('p').text()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment