forked from vercel/next.js
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
vercel#42398 fix(app-render): escape segment value
- Loading branch information
1 parent
c030b3e
commit c0a0480
Showing
4 changed files
with
18 additions
and
139 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,5 @@ | ||
import { | ||
DynamicParamTypesShort, | ||
FlightRouterState, | ||
} from '../../server/app-render' | ||
|
||
export const RSC = 'RSC' as const | ||
export const NEXT_ROUTER_STATE_TREE = 'Next-Router-State-Tree' as const | ||
export const NEXT_ROUTER_PREFETCH = 'Next-Router-Prefetch' as const | ||
export const RSC_VARY_HEADER = | ||
`${RSC}, ${NEXT_ROUTER_STATE_TREE}, ${NEXT_ROUTER_PREFETCH}` as const | ||
|
||
export const escapeFlightRouterState = ( | ||
state: FlightRouterState | ||
): FlightRouterState => { | ||
const [segment, parallelRoutes, ...restState] = state | ||
const escapedParallelRoutes: typeof parallelRoutes = Object.create({}) | ||
let escapedSegment: typeof segment = segment | ||
|
||
if (typeof segment !== 'string') { | ||
const [param, value, type] = segment | ||
const escapedSegmentValue = encodeURIComponent(value) | ||
escapedSegment = [ | ||
param, | ||
escapedSegmentValue, | ||
type as DynamicParamTypesShort, | ||
] | ||
} | ||
|
||
Object.keys(parallelRoutes).forEach((key) => { | ||
const childState = parallelRoutes[key] | ||
|
||
escapedParallelRoutes[key] = escapeFlightRouterState(childState) | ||
}) | ||
|
||
return [escapedSegment, escapedParallelRoutes, ...restState] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.