Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make dynamic routes case-sensitive #15444

Merged
merged 5 commits into from
Jul 25, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/next/next-server/lib/router/utils/route-regex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,15 +107,15 @@ export function getRouteRegex(
.join('')

return {
re: new RegExp(`^${parameterizedRoute}(?:/)?$`, 'i'),
re: new RegExp(`^${parameterizedRoute}(?:/)?$`),
groups,
routeKeys,
namedRegex: `^${namedParameterizedRoute}(?:/)?$`,
}
}

return {
re: new RegExp(`^${parameterizedRoute}(?:/)?$`, 'i'),
re: new RegExp(`^${parameterizedRoute}(?:/)?$`),
groups,
}
}
13 changes: 13 additions & 0 deletions test/integration/client-navigation/pages/dynamic/[slug]/route.js
Original file line number Diff line number Diff line change
@@ -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 <p>{this.props.query.slug}</p>
}
}
23 changes: 23 additions & 0 deletions test/integration/client-navigation/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ describe('Client Navigation', () => {
'/url-prop-override',

'/dynamic/ssr',
'/dynamic/[slug]/route',

'/nav',
'/nav/about',
Expand Down Expand Up @@ -1002,6 +1003,28 @@ 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()
})

// this test is failing
Janpot marked this conversation as resolved.
Show resolved Hide resolved
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()
Expand Down