File tree 1 file changed +16
-5
lines changed
packages/open-next/src/core/routing 1 file changed +16
-5
lines changed Original file line number Diff line number Diff line change @@ -129,6 +129,21 @@ async function generateResult(
129
129
} ,
130
130
} ;
131
131
}
132
+
133
+ /**
134
+ *
135
+ * https://github.com/vercel/next.js/blob/34039551d2e5f611c0abde31a197d9985918adaf/packages/next/src/shared/lib/router/utils/escape-path-delimiters.ts#L2-L10
136
+ */
137
+ function escapePathDelimiters (
138
+ segment : string ,
139
+ escapeEncoded ?: boolean ,
140
+ ) : string {
141
+ return segment . replace (
142
+ new RegExp ( `([/#?]${ escapeEncoded ? "|%(2f|23|3f|5c)" : "" } )` , "gi" ) ,
143
+ ( char : string ) => encodeURIComponent ( char ) ,
144
+ ) ;
145
+ }
146
+
132
147
/**
133
148
*
134
149
* SSG cache key needs to be decoded, but some characters needs to be properly escaped
@@ -139,11 +154,7 @@ function decodePathParams(pathname: string): string {
139
154
. split ( "/" )
140
155
. map ( ( segment ) => {
141
156
try {
142
- // https://github.com/vercel/next.js/blob/34039551d2e5f611c0abde31a197d9985918adaf/packages/next/src/shared/lib/router/utils/escape-path-delimiters.ts#L2-L10
143
- return decodeURIComponent ( segment ) . replace (
144
- / ( [ \/ # ? ] | % ( 2 f | 2 3 | 3 f | 5 c ) ) / gi,
145
- ( char : string ) => encodeURIComponent ( char ) ,
146
- ) ;
157
+ return escapePathDelimiters ( decodeURIComponent ( segment ) , true ) ;
147
158
} catch ( e ) {
148
159
// If decodeURIComponent fails, we return the original segment
149
160
return segment ;
You can’t perform that action at this time.
0 commit comments