3003bff6fa
In a previous PR (https://github.com/vercel/next.js/pull/46753), the `originalSource` was saved to be passed along through the build process. This was done a bit too late in the flow, which made `originalSource` include some transformations. Because `originalSource` is used for display purposes, we need it unmodified. This PR preserves `originalSource`.
37 lines
1.3 KiB
TypeScript
37 lines
1.3 KiB
TypeScript
/* eslint-env jest */
|
|
import { getMiddlewareMatchers } from 'next/dist/build/analysis/get-page-static-info'
|
|
|
|
describe('get-page-static-infos', () => {
|
|
describe('getMiddlewareMatchers', () => {
|
|
it('sets originalSource with one matcher', () => {
|
|
const matchers = '/middleware/path'
|
|
const expected = [
|
|
{
|
|
originalSource: '/middleware/path',
|
|
regexp:
|
|
'^(?:\\/(_next\\/data\\/[^/]{1,}))?\\/middleware\\/path(.json)?[\\/#\\?]?$',
|
|
},
|
|
]
|
|
const result = getMiddlewareMatchers(matchers, { i18n: undefined })
|
|
expect(result).toStrictEqual(expected)
|
|
})
|
|
|
|
it('sets originalSource with multiple matchers', () => {
|
|
const matchers = ['/middleware/path', '/middleware/another-path']
|
|
const expected = [
|
|
{
|
|
originalSource: '/middleware/path',
|
|
regexp:
|
|
'^(?:\\/(_next\\/data\\/[^/]{1,}))?\\/middleware\\/path(.json)?[\\/#\\?]?$',
|
|
},
|
|
{
|
|
originalSource: '/middleware/another-path',
|
|
regexp:
|
|
'^(?:\\/(_next\\/data\\/[^/]{1,}))?\\/middleware\\/another-path(.json)?[\\/#\\?]?$',
|
|
},
|
|
]
|
|
const result = getMiddlewareMatchers(matchers, { i18n: undefined })
|
|
expect(result).toStrictEqual(expected)
|
|
})
|
|
})
|
|
})
|