Lint: the new route inventory, its tests and the touched tests

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
Radosław Smoliński
2026-11-26 20:33:04 +01:00
co-authored by Claude Opus 5.5
parent d4fe3bf4ba
commit 8f443c9214
8 changed files with 19 additions and 18 deletions
+3 -3
View File
@@ -16,13 +16,13 @@ const { getMiddlewareMatchers } = createRequire(import.meta.url)(path.join(next,
getMiddlewareMatchers: (matchers: string[], nextConfig: object) => { regexp: string }[]
}
const runs = (matcher: string) => {
const re = new RegExp(getMiddlewareMatchers([matcher], {})[0]!.regexp)
const re = new RegExp(getMiddlewareMatchers([matcher], {})[0].regexp)
return (pathname: string) => re.test(pathname)
}
describe('the proxy matcher', () => {
test('skips /api, /admin and /_next as whole segments and files; runs on pages that only START with those letters', () => {
const proxy = runs(DEFAULT_PROXY_MATCHER[0]!)
const proxy = runs(DEFAULT_PROXY_MATCHER[0])
for (const skipped of ['/api', '/api/users', '/api/ipal/hit', '/admin', '/admin/', '/admin/collections/users', '/_next/static/chunk.js', '/robots.txt', '/sitemap.xml']) {
expect([skipped, proxy(skipped)]).toEqual([skipped, false])
}
@@ -33,6 +33,6 @@ describe('the proxy matcher', () => {
test('the reference site uses the same literal (Next reads it statically, it cannot be imported)', () => {
const proxyFile = readFileSync(path.join(root, 'reference/src/proxy.ts'), 'utf8')
expect(proxyFile).toContain(`matcher: ['${DEFAULT_PROXY_MATCHER[0]!.replace(/\\/g, '\\\\')}']`)
expect(proxyFile).toContain(`matcher: ['${DEFAULT_PROXY_MATCHER[0].replace(/\\/g, '\\\\')}']`)
})
})