@@ -3,9 +3,8 @@ import { existsSync } from 'fs'
33
44import { ROOT } from '../lib/constants.js'
55import Page from '../lib/page.js'
6- import { languageKeys } from '../lib/languages.js'
6+ import { languagePrefixPathRegex } from '../lib/languages.js'
77
8- const languagePrefixRegex = new RegExp ( `^/(${ languageKeys . join ( '|' ) } )(/|$)` )
98const englishPrefixRegex = / ^ \/ e n ( \/ | $ ) /
109const CONTENT_ROOT = path . join ( ROOT , 'content' )
1110
@@ -18,7 +17,7 @@ export default async function findPage(
1817 { isDev = process . env . NODE_ENV === 'development' , contentRoot = CONTENT_ROOT } = { }
1918) {
2019 // Filter out things like `/will/redirect` or `/_next/data/...`
21- if ( ! languagePrefixRegex . test ( req . pagePath ) ) {
20+ if ( ! languagePrefixPathRegex . test ( req . pagePath ) ) {
2221 return next ( )
2322 }
2423
@@ -58,8 +57,8 @@ export default async function findPage(
5857}
5958
6059async function rereadByPath ( uri , contentRoot , currentVersion ) {
61- const languageCode = uri . match ( languagePrefixRegex ) [ 1 ]
62- const withoutLanguage = uri . replace ( languagePrefixRegex , '/' )
60+ const languageCode = uri . match ( languagePrefixPathRegex ) [ 1 ]
61+ const withoutLanguage = uri . replace ( languagePrefixPathRegex , '/' )
6362 const withoutVersion = withoutLanguage . replace ( `/${ currentVersion } ` , '' )
6463 // TODO: Support loading translations the same way.
6564 // NOTE: No one is going to test translations like this in development
0 commit comments