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
b9684573
Commit
b9684573
authored
Jan 14, 2026
by
Jiachi Liu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
more test cases
parent
92fd4b35
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
340 additions
and
0 deletions
+340
-0
route.js
...ii-headers/with-middleware/app/api/route-headers/route.js
+0
-0
layout.js
test/e2e/non-ascii-headers/with-middleware/app/layout.js
+0
-0
page.js
test/e2e/non-ascii-headers/with-middleware/app/page.js
+0
-0
middleware.js
test/e2e/non-ascii-headers/with-middleware/middleware.js
+0
-0
next.config.js
test/e2e/non-ascii-headers/with-middleware/next.config.js
+0
-0
headers.js
...2e/non-ascii-headers/with-middleware/pages/api/headers.js
+0
-0
with-middleware.test.ts
...non-ascii-headers/with-middleware/with-middleware.test.ts
+202
-0
route.js
...headers/without-middleware/app/api/route-headers/route.js
+18
-0
layout.js
test/e2e/non-ascii-headers/without-middleware/app/layout.js
+7
-0
page.js
test/e2e/non-ascii-headers/without-middleware/app/page.js
+3
-0
next.config.js
test/e2e/non-ascii-headers/without-middleware/next.config.js
+1
-0
headers.js
...non-ascii-headers/without-middleware/pages/api/headers.js
+7
-0
without-middleware.test.ts
...cii-headers/without-middleware/without-middleware.test.ts
+102
-0
No files found.
test/e2e/
middleware-non-ascii-headers/app
/app/api/route-headers/route.js
→
test/e2e/
non-ascii-headers/with-middleware
/app/api/route-headers/route.js
View file @
b9684573
File moved
test/e2e/
middleware-non-ascii-headers/app
/app/layout.js
→
test/e2e/
non-ascii-headers/with-middleware
/app/layout.js
View file @
b9684573
File moved
test/e2e/
middleware-non-ascii-headers/app
/app/page.js
→
test/e2e/
non-ascii-headers/with-middleware
/app/page.js
View file @
b9684573
File moved
test/e2e/
middleware-non-ascii-headers/app
/middleware.js
→
test/e2e/
non-ascii-headers/with-middleware
/middleware.js
View file @
b9684573
File moved
test/e2e/
middleware-non-ascii-headers/app
/next.config.js
→
test/e2e/
non-ascii-headers/with-middleware
/next.config.js
View file @
b9684573
File moved
test/e2e/
middleware-non-ascii-headers/app
/pages/api/headers.js
→
test/e2e/
non-ascii-headers/with-middleware
/pages/api/headers.js
View file @
b9684573
File moved
test/e2e/
middleware-non-ascii-headers/middleware-non-ascii-headers
.test.ts
→
test/e2e/
non-ascii-headers/with-middleware/with-middleware
.test.ts
View file @
b9684573
This diff is collapsed.
Click to expand it.
test/e2e/non-ascii-headers/without-middleware/app/api/route-headers/route.js
0 → 100644
View file @
b9684573
/**
* App Route handler that reads request headers (tests NextRequest header conversion)
*/
export
async
function
GET
(
request
)
{
// Read incoming request headers
const
requestHeaders
=
{}
for
(
const
[
key
,
value
]
of
request
.
headers
.
entries
())
{
if
(
key
.
startsWith
(
'x-'
))
{
requestHeaders
[
key
]
=
value
}
}
return
new
Response
(
JSON
.
stringify
(
requestHeaders
),
{
headers
:
{
'Content-Type'
:
'application/json'
,
},
})
}
test/e2e/non-ascii-headers/without-middleware/app/layout.js
0 → 100644
View file @
b9684573
export
default
function
RootLayout
({
children
})
{
return
(
<
html
>
<
body
>
{
children
}
<
/body
>
<
/html
>
)
}
test/e2e/non-ascii-headers/without-middleware/app/page.js
0 → 100644
View file @
b9684573
export
default
function
Page
()
{
return
<
div
>
Hello
<
/div
>
}
test/e2e/non-ascii-headers/without-middleware/next.config.js
0 → 100644
View file @
b9684573
module
.
exports
=
{}
test/e2e/non-ascii-headers/without-middleware/pages/api/headers.js
0 → 100644
View file @
b9684573
/**
* API route that returns all request headers as JSON.
* Used to verify header handling WITHOUT middleware.
*/
export
default
function
handler
(
req
,
res
)
{
res
.
status
(
200
).
json
(
req
.
headers
)
}
test/e2e/non-ascii-headers/without-middleware/without-middleware.test.ts
0 → 100644
View file @
b9684573
import
{
nextTestSetup
}
from
'e2e-utils'
/**
* Test behavior of headers WITHOUT middleware.
* See: https://github.com/vercel/next.js/pull/88237/files#r2677631301
*/
/**
* Converts a UTF-8 string to its Mojibake representation.
* This simulates what happens when UTF-8 bytes are interpreted as Latin-1.
*/
function
toMojibake
(
str
:
string
):
string
{
const
encoder
=
new
TextEncoder
()
// UTF-8
const
bytes
=
encoder
.
encode
(
str
)
// Interpret UTF-8 bytes as Latin-1 characters
return
Array
.
from
(
bytes
)
.
map
((
b
)
=>
String
.
fromCharCode
(
b
))
.
join
(
''
)
}
describe
(
'Non-ASCII Headers Without Middleware'
,
()
=>
{
const
{
next
}
=
nextTestSetup
({
files
:
__dirname
,
})
it
(
'should NOT decode mojibake headers without middleware'
,
async
()
=>
{
// Without middleware, mojibake recovery does NOT happen for Pages API routes.
const
res
=
await
next
.
fetch
(
'/api/headers'
,
{
headers
:
{
'x-city'
:
toMojibake
(
'Montréal'
),
'x-country'
:
toMojibake
(
'Österreich'
),
},
})
expect
(
res
.
status
).
toBe
(
200
)
const
headers
=
await
res
.
json
()
// Without middleware, mojibake is NOT recovered - raw bytes pass through
expect
(
headers
[
'x-city'
]).
toBe
(
toMojibake
(
'Montréal'
))
expect
(
headers
[
'x-country'
]).
toBe
(
toMojibake
(
'Österreich'
))
})
it
(
'should preserve intentional percent-encoding without middleware'
,
async
()
=>
{
const
res
=
await
next
.
fetch
(
'/api/headers'
,
{
headers
:
{
'x-path'
:
'/hello%2Fworld'
,
'x-query'
:
'foo%20bar'
,
},
})
expect
(
res
.
status
).
toBe
(
200
)
const
headers
=
await
res
.
json
()
// Intentional percent-encoding should be preserved
expect
(
headers
[
'x-path'
]).
toBe
(
'/hello%2Fworld'
)
expect
(
headers
[
'x-query'
]).
toBe
(
'foo%20bar'
)
})
it
(
'should pass through pure ASCII headers unchanged without middleware'
,
async
()
=>
{
const
res
=
await
next
.
fetch
(
'/api/headers'
,
{
headers
:
{
'x-simple'
:
'hello-world'
,
'x-number'
:
'12345'
,
},
})
expect
(
res
.
status
).
toBe
(
200
)
const
headers
=
await
res
.
json
()
expect
(
headers
[
'x-simple'
]).
toBe
(
'hello-world'
)
expect
(
headers
[
'x-number'
]).
toBe
(
'12345'
)
})
describe
(
'App Route Handler'
,
()
=>
{
it
(
'should decode mojibake headers in route handler'
,
async
()
=>
{
// App Route handlers decode mojibake even without middleware.
// This is different from Pages API routes.
const
res
=
await
next
.
fetch
(
'/api/route-headers'
,
{
headers
:
{
'x-city'
:
toMojibake
(
'Montréal'
),
'x-country'
:
toMojibake
(
'Österreich'
),
},
})
expect
(
res
.
status
).
toBe
(
200
)
const
body
=
await
res
.
json
()
expect
(
body
[
'x-city'
]).
toBe
(
'Montréal'
)
expect
(
body
[
'x-country'
]).
toBe
(
'Österreich'
)
})
it
(
'should preserve intentional percent-encoding in route handler without middleware'
,
async
()
=>
{
const
res
=
await
next
.
fetch
(
'/api/route-headers'
,
{
headers
:
{
'x-path'
:
'/hello%2Fworld'
,
'x-query'
:
'foo%20bar'
,
},
})
expect
(
res
.
status
).
toBe
(
200
)
const
body
=
await
res
.
json
()
expect
(
body
[
'x-path'
]).
toBe
(
'/hello%2Fworld'
)
expect
(
body
[
'x-query'
]).
toBe
(
'foo%20bar'
)
})
})
})
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