@@ -16,7 +16,10 @@ import {
1616} from '../shared/lib/router/utils/prepare-destination'
1717import { removeTrailingSlash } from '../shared/lib/router/utils/remove-trailing-slash'
1818import { normalizeRscURL } from '../shared/lib/router/utils/app-paths'
19- import { NEXT_QUERY_PARAM_PREFIX } from '../lib/constants'
19+ import {
20+ NEXT_INTERCEPTION_MARKER_PREFIX ,
21+ NEXT_QUERY_PARAM_PREFIX ,
22+ } from '../lib/constants'
2023
2124export function normalizeVercelUrl (
2225 req : BaseNextRequest ,
@@ -32,9 +35,17 @@ export function normalizeVercelUrl(
3235 delete ( _parsedUrl as any ) . search
3336
3437 for ( const key of Object . keys ( _parsedUrl . query ) ) {
38+ const isNextQueryPrefix =
39+ key !== NEXT_QUERY_PARAM_PREFIX &&
40+ key . startsWith ( NEXT_QUERY_PARAM_PREFIX )
41+
42+ const isNextInterceptionMarkerPrefix =
43+ key !== NEXT_INTERCEPTION_MARKER_PREFIX &&
44+ key . startsWith ( NEXT_INTERCEPTION_MARKER_PREFIX )
45+
3546 if (
36- ( key !== NEXT_QUERY_PARAM_PREFIX &&
37- key . startsWith ( NEXT_QUERY_PARAM_PREFIX ) ) ||
47+ isNextQueryPrefix ||
48+ isNextInterceptionMarkerPrefix ||
3849 ( paramKeys || Object . keys ( defaultRouteRegex . groups ) ) . includes ( key )
3950 ) {
4051 delete _parsedUrl . query [ key ]
@@ -44,6 +55,24 @@ export function normalizeVercelUrl(
4455 }
4556}
4657
58+ /**
59+ * Normalizes `nxtP` and `nxtI` query param values to remove the prefix.
60+ * This function does not mutate the input key; it calls the provided function
61+ * with the normalized key.
62+ */
63+ export function normalizeNextQueryParam (
64+ key : string ,
65+ onKeyNormalized : ( normalizedKey : string ) => void
66+ ) {
67+ const prefixes = [ NEXT_QUERY_PARAM_PREFIX , NEXT_INTERCEPTION_MARKER_PREFIX ]
68+ for ( const prefix of prefixes ) {
69+ if ( key !== prefix && key . startsWith ( prefix ) ) {
70+ const normalizedKey = key . substring ( prefix . length )
71+ onKeyNormalized ( normalizedKey )
72+ }
73+ }
74+ }
75+
4776export function interpolateDynamicPath (
4877 pathname : string ,
4978 params : ParsedUrlQuery ,
0 commit comments