Skip to content

Commit 40c2ba9

Browse files
authored
[lts-active] Match Next data paths case-sensitively (#196)
1 parent 2d9f50a commit 40c2ba9

2 files changed

Lines changed: 18 additions & 1 deletion

File tree

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { matchNextDataPathname } from './match-next-data-pathname'
2+
3+
describe('matchNextDataPathname', () => {
4+
it('matches the exact internal route', () => {
5+
expect(matchNextDataPathname('/_next/data/build-id/index.json')).toEqual({
6+
path: ['build-id', 'index.json'],
7+
})
8+
})
9+
10+
it.each([
11+
'/_NEXT/data/build-id/index.json',
12+
'/_next/DATA/build-id/index.json',
13+
'/_NeXt/DaTa/build-id/index.json',
14+
])('does not match a case variant: %s', (pathname) => {
15+
expect(matchNextDataPathname(pathname)).toBe(false)
16+
})
17+
})

‎packages/next/src/server/lib/match-next-data-pathname.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { getPathMatch } from '../../shared/lib/router/utils/path-match'
22

3-
const matcher = getPathMatch('/_next/data/:path*')
3+
const matcher = getPathMatch('/_next/data/:path*', { sensitive: true })
44

55
export function matchNextDataPathname(pathname: string | null | undefined) {
66
if (typeof pathname !== 'string') return false

0 commit comments

Comments
 (0)