Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
N
next.js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alex
next.js
Commits
17353cc6
Commit
17353cc6
authored
Apr 14, 2026
by
Tim Neutkens
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Port test from vercel/vercel
parent
93af1eb0
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
99 additions
and
0 deletions
+99
-0
i18n-beforefiles-rewrite.ts
...tion/i18n-beforefiles-rewrite/i18n-beforefiles-rewrite.ts
+59
-0
middleware.js
test/production/i18n-beforefiles-rewrite/middleware.js
+5
-0
next.config.js
test/production/i18n-beforefiles-rewrite/next.config.js
+17
-0
[slug].tsx
...uction/i18n-beforefiles-rewrite/pages/[teamId]/[slug].tsx
+3
-0
[id].tsx
...roduction/i18n-beforefiles-rewrite/pages/dynamic/[id].tsx
+3
-0
static.tsx
...duction/i18n-beforefiles-rewrite/pages/dynamic/static.tsx
+3
-0
a.tsx
test/production/i18n-beforefiles-rewrite/pages/home/a.tsx
+3
-0
b.tsx
test/production/i18n-beforefiles-rewrite/pages/home/b.tsx
+3
-0
index.tsx
test/production/i18n-beforefiles-rewrite/pages/index.tsx
+3
-0
No files found.
test/production/i18n-beforefiles-rewrite/i18n-beforefiles-rewrite.ts
0 → 100644
View file @
17353cc6
import
{
nextTestSetup
}
from
'e2e-utils'
import
fs
from
'fs'
import
path
from
'path'
describe
(
'i18n-beforefiles-rewrite'
,
()
=>
{
const
{
next
}
=
nextTestSetup
({
files
:
__dirname
,
})
const
locales
=
[
'en'
,
'fr'
]
// Auto-static pages (no getStaticProps / getServerSideProps) that should
// only have locale-prefixed HTML in server/pages/ when i18n is configured.
const
autoStaticPages
=
[
'index'
,
'home/a'
,
'home/b'
,
'dynamic/static'
,
'dynamic/[id]'
,
'[teamId]/[slug]'
,
]
it
(
'should not produce non-locale-prefixed HTML files for auto-static pages'
,
()
=>
{
const
pagesDir
=
path
.
join
(
next
.
testDir
,
'.next/server/pages'
)
for
(
const
page
of
autoStaticPages
)
{
const
orphanPath
=
path
.
join
(
pagesDir
,
`
${
page
}
.html`
)
expect
({
page
,
exists
:
fs
.
existsSync
(
orphanPath
),
}).
toEqual
({
page
,
exists
:
false
})
}
})
it
(
'should have locale-prefixed HTML files for auto-static pages'
,
()
=>
{
const
pagesDir
=
path
.
join
(
next
.
testDir
,
'.next/server/pages'
)
for
(
const
page
of
autoStaticPages
)
{
for
(
const
locale
of
locales
)
{
const
localePath
=
page
===
'index'
?
path
.
join
(
pagesDir
,
`
${
locale
}
.html`
)
:
path
.
join
(
pagesDir
,
locale
,
`
${
page
}
.html`
)
expect
({
page
:
`
${
locale
}
/
${
page
}
`
,
exists
:
fs
.
existsSync
(
localePath
),
}).
toEqual
({
page
:
`
${
locale
}
/
${
page
}
`
,
exists
:
true
})
}
}
})
it
(
'should 404 for /rewrite-before-files'
,
async
()
=>
{
// beforeFiles rewrites /rewrite-before-files to /somewhere.
// /somewhere does not match any page, so this should 404.
// Before the fix, orphan [teamId]/[slug].html would incorrectly match.
const
res
=
await
next
.
fetch
(
'/rewrite-before-files'
)
expect
(
res
.
status
).
toBe
(
404
)
})
})
test/production/i18n-beforefiles-rewrite/middleware.js
0 → 100644
View file @
17353cc6
import
{
NextResponse
}
from
'next/server'
export
function
middleware
(
request
)
{
return
NextResponse
.
next
()
}
test/production/i18n-beforefiles-rewrite/next.config.js
0 → 100644
View file @
17353cc6
module
.
exports
=
{
i18n
:
{
locales
:
[
'en'
,
'fr'
],
defaultLocale
:
'en'
,
},
rewrites
()
{
return
{
beforeFiles
:
[
{
source
:
'/rewrite-before-files'
,
destination
:
'/somewhere'
,
},
],
afterFiles
:
[],
}
},
}
test/production/i18n-beforefiles-rewrite/pages/[teamId]/[slug].tsx
0 → 100644
View file @
17353cc6
export
default
function
Page
()
{
return
<
p
>
/[teamId]/[slug]
</
p
>
}
test/production/i18n-beforefiles-rewrite/pages/dynamic/[id].tsx
0 → 100644
View file @
17353cc6
export
default
function
Page
()
{
return
<
p
>
dynamic route
</
p
>
}
test/production/i18n-beforefiles-rewrite/pages/dynamic/static.tsx
0 → 100644
View file @
17353cc6
export
default
function
Page
()
{
return
<
p
>
static route
</
p
>
}
test/production/i18n-beforefiles-rewrite/pages/home/a.tsx
0 → 100644
View file @
17353cc6
export
default
function
Page
()
{
return
<
p
>
Home A
</
p
>
}
test/production/i18n-beforefiles-rewrite/pages/home/b.tsx
0 → 100644
View file @
17353cc6
export
default
function
Page
()
{
return
<
p
>
Home B
</
p
>
}
test/production/i18n-beforefiles-rewrite/pages/index.tsx
0 → 100644
View file @
17353cc6
export
default
function
Page
()
{
return
<
p
>
index
</
p
>
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment