@@ -208,8 +208,10 @@ export function resolvePath({
208208interface InterpolatePathOptions {
209209 path ?: string
210210 params : Record < string , unknown >
211- // Map of encoded chars to decoded chars (e.g. '%40' -> '@') that should remain decoded in path params
211+ /** Map of encoded chars to decoded chars (e.g. '%40' -> '@') that should remain decoded in path params */
212212 decodeCharMap ?: Map < string , string >
213+ /** whether to encode the interpolated params (defaults: true) */
214+ encode ?: boolean
213215}
214216
215217type InterPolatePathResult = {
@@ -248,6 +250,7 @@ export function interpolatePath({
248250 path,
249251 params,
250252 decodeCharMap,
253+ encode = true ,
251254} : InterpolatePathOptions ) : InterPolatePathResult {
252255 // Tracking if any params are missing in the `params` object
253256 // when interpolating the path
@@ -298,7 +301,9 @@ export function interpolatePath({
298301 continue
299302 }
300303
301- const value = encodeParam ( '_splat' , params , decodeCharMap )
304+ const value = encode
305+ ? encodeParam ( '_splat' , params , decodeCharMap )
306+ : params . _splat
302307 joined += '/' + prefix + value + suffix
303308 continue
304309 }
@@ -312,7 +317,9 @@ export function interpolatePath({
312317
313318 const prefix = path . substring ( start , segment [ 1 ] )
314319 const suffix = path . substring ( segment [ 4 ] , end )
315- const value = encodeParam ( key , params , decodeCharMap ) ?? 'undefined'
320+ const value =
321+ ( encode ? encodeParam ( key , params , decodeCharMap ) : params [ key ] ) ??
322+ 'undefined'
316323 joined += '/' + prefix + value + suffix
317324 continue
318325 }
@@ -335,7 +342,8 @@ export function interpolatePath({
335342
336343 usedParams [ key ] = valueRaw
337344
338- const value = encodeParam ( key , params , decodeCharMap ) ?? ''
345+ const value =
346+ ( encode ? encodeParam ( key , params , decodeCharMap ) : params [ key ] ) ?? ''
339347 joined += '/' + prefix + value + suffix
340348 continue
341349 }
0 commit comments