mirror of
https://github.com/hanzoai/next.js.git
synced 2026-09-24 17:00:51 +00:00
For a given path expression, we want it to optionally match a `.json`
suffix. However, the original implementation was flawed:
The path `/:id` was altered to `/:id(.json)?`, which then converted to
the Regex pattern `^(?:\/(.json))?[\/#\?]?$`. This Regex incorrectly
matched only `/` or `/_json` — clearly not the intended result.
The fix involved adjusting the way we append the `.json` suffix. Instead
of `/:id(.json)?`, we now use `/:id{(\\.json)}?`, which converts to the
Regex `^(?:\/([^\/#\?]+?))(\.json)?[\/#\?]?$`. This pattern correctly
matches both cases, with or without the `.json` suffix.
-----
Fixes https://github.com/vercel/next.js/issues/53840
Fixes https://github.com/vercel/next.js/issues/55558
Closes DX-2088
18 lines
418 B
TypeScript
18 lines
418 B
TypeScript
import { nextTestSetup } from 'e2e-utils'
|
|
|
|
describe('app dir - middleware with custom matcher', () => {
|
|
const { next, skipped } = nextTestSetup({
|
|
files: __dirname,
|
|
skipDeployment: true,
|
|
})
|
|
|
|
if (skipped) {
|
|
return
|
|
}
|
|
|
|
it('should match /:id (without asterisk)', async () => {
|
|
const browser = await next.browser('/chat/123')
|
|
expect(await browser.elementByCss('p').text()).toBe('Home')
|
|
})
|
|
})
|