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
434d9daf
Commit
434d9daf
authored
Jan 07, 2026
by
Jiachi Liu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remove reexport helper
parent
a6e9da93
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
22 deletions
+27
-22
base-server.ts
packages/next/src/server/base-server.ts
+3
-3
resolve-routes.ts
packages/next/src/server/lib/router-utils/resolve-routes.ts
+6
-3
utils.test.ts
packages/next/src/server/web/utils.test.ts
+18
-16
No files found.
packages/next/src/server/base-server.ts
View file @
434d9daf
...
...
@@ -111,7 +111,7 @@ import {
import
{
BaseServerSpan
}
from
'./lib/trace/constants'
import
{
I18NProvider
}
from
'./lib/i18n-provider'
import
{
sendResponse
}
from
'./send-response'
import
{
normalizeNextQueryParam
,
decodeHeaderValue
}
from
'./web/utils'
import
{
normalizeNextQueryParam
,
decode
Node
HeaderValue
}
from
'./web/utils'
import
{
HTML_CONTENT_TYPE_HEADER
,
JSON_CONTENT_TYPE_HEADER
,
...
...
@@ -953,9 +953,9 @@ export default abstract class Server<
const
trimmedName
=
headerName
.
trim
()
const
headerValue
=
req
.
headers
[
trimmedName
]
if
(
typeof
headerValue
===
'string'
)
{
req
.
headers
[
trimmedName
]
=
decodeHeaderValue
(
headerValue
)
req
.
headers
[
trimmedName
]
=
decode
Node
HeaderValue
(
headerValue
)
}
else
if
(
Array
.
isArray
(
headerValue
))
{
req
.
headers
[
trimmedName
]
=
headerValue
.
map
(
decodeHeaderValue
)
req
.
headers
[
trimmedName
]
=
headerValue
.
map
(
decode
Node
HeaderValue
)
}
}
// Clean up the marker header
...
...
packages/next/src/server/lib/router-utils/resolve-routes.ts
View file @
434d9daf
...
...
@@ -14,7 +14,10 @@ import { getCloneableBody } from '../../body-streams'
import
{
filterReqHeaders
,
ipcForbiddenHeaders
}
from
'../server-ipc/utils'
import
{
stringifyQuery
}
from
'../../server-route-utils'
import
{
formatHostname
}
from
'../format-hostname'
import
{
toNodeOutgoingHttpHeaders
,
decodeHeaderValue
}
from
'../../web/utils'
import
{
toNodeOutgoingHttpHeaders
,
decodeNodeHeaderValue
,
}
from
'../../web/utils'
import
{
isAbortError
}
from
'../../pipe-readable'
import
{
getHostname
}
from
'../../../shared/lib/get-hostname'
import
{
...
...
@@ -616,8 +619,8 @@ export function getResolveRoutes(
encodedValue
==
null
?
undefined
:
typeof
encodedValue
===
'string'
?
decodeHeaderValue
(
encodedValue
)
:
encodedValue
.
map
(
decodeHeaderValue
)
?
decode
Node
HeaderValue
(
encodedValue
)
:
encodedValue
.
map
(
decode
Node
HeaderValue
)
const
oldValue
=
req
.
headers
[
key
]
if
(
oldValue
!==
newValue
)
{
...
...
packages/next/src/server/web/utils.test.ts
View file @
434d9daf
import
{
toNodeOutgoingHttpHeaders
,
encodeHeaderValue
,
decodeHeaderValue
,
decode
Node
HeaderValue
,
}
from
'./utils'
describe
(
'toNodeHeaders'
,
()
=>
{
...
...
@@ -80,35 +80,37 @@ describe('encodeHeaderValue', () => {
})
})
describe
(
'decodeHeaderValue'
,
()
=>
{
describe
(
'decode
Node
HeaderValue'
,
()
=>
{
it
(
'should return unencoded values unchanged'
,
()
=>
{
expect
(
decodeHeaderValue
(
'hello-world'
)).
toBe
(
'hello-world'
)
expect
(
decodeHeaderValue
(
'test_value'
)).
toBe
(
'test_value'
)
expect
(
decodeHeaderValue
(
'123'
)).
toBe
(
'123'
)
expect
(
decode
Node
HeaderValue
(
'hello-world'
)).
toBe
(
'hello-world'
)
expect
(
decode
Node
HeaderValue
(
'test_value'
)).
toBe
(
'test_value'
)
expect
(
decode
Node
HeaderValue
(
'123'
)).
toBe
(
'123'
)
})
it
(
'should decode percent-encoded values'
,
()
=>
{
expect
(
decodeHeaderValue
(
'Montr%C3%A9al'
)).
toBe
(
'Montréal'
)
expect
(
decodeHeaderValue
(
'caf%C3%A9'
)).
toBe
(
'café'
)
expect
(
decodeHeaderValue
(
'%E5%8C%97%E4%BA%AC'
)).
toBe
(
'北京'
)
expect
(
decode
Node
HeaderValue
(
'Montr%C3%A9al'
)).
toBe
(
'Montréal'
)
expect
(
decode
Node
HeaderValue
(
'caf%C3%A9'
)).
toBe
(
'café'
)
expect
(
decode
Node
HeaderValue
(
'%E5%8C%97%E4%BA%AC'
)).
toBe
(
'北京'
)
expect
(
decodeHeaderValue
(
'%D1%80%D1%83%D1%81%D1%81%D0%BA%D0%B8%D0%B9'
)
decode
Node
HeaderValue
(
'%D1%80%D1%83%D1%81%D1%81%D0%BA%D0%B8%D0%B9'
)
).
toBe
(
'русский'
)
})
it
(
'should handle spaces correctly'
,
()
=>
{
expect
(
decodeHeaderValue
(
'hello world'
)).
toBe
(
'hello world'
)
expect
(
decodeHeaderValue
(
'Montr%C3%A9al%20city'
)).
toBe
(
'Montréal city'
)
expect
(
decode
Node
HeaderValue
(
'hello world'
)).
toBe
(
'hello world'
)
expect
(
decode
Node
HeaderValue
(
'Montr%C3%A9al%20city'
)).
toBe
(
'Montréal city'
)
})
it
(
'should handle mixed encoded and unencoded values'
,
()
=>
{
expect
(
decodeHeaderValue
(
'City%3A%20Montr%C3%A9al'
)).
toBe
(
'City: Montréal'
)
expect
(
decodeNodeHeaderValue
(
'City%3A%20Montr%C3%A9al'
)).
toBe
(
'City: Montréal'
)
})
it
(
'should return original value if decoding fails'
,
()
=>
{
expect
(
decodeHeaderValue
(
'invalid%'
)).
toBe
(
'invalid%'
)
expect
(
decodeHeaderValue
(
'invalid%2'
)).
toBe
(
'invalid%2'
)
expect
(
decodeHeaderValue
(
'%XX'
)).
toBe
(
'%XX'
)
expect
(
decode
Node
HeaderValue
(
'invalid%'
)).
toBe
(
'invalid%'
)
expect
(
decode
Node
HeaderValue
(
'invalid%2'
)).
toBe
(
'invalid%2'
)
expect
(
decode
Node
HeaderValue
(
'%XX'
)).
toBe
(
'%XX'
)
})
it
(
'should round-trip encode/decode correctly'
,
()
=>
{
...
...
@@ -122,7 +124,7 @@ describe('decodeHeaderValue', () => {
]
for
(
const
value
of
testValues
)
{
expect
(
decodeHeaderValue
(
encodeHeaderValue
(
value
))).
toBe
(
value
)
expect
(
decode
Node
HeaderValue
(
encodeHeaderValue
(
value
))).
toBe
(
value
)
}
})
})
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