Skip to content

Commit cc94123

Browse files
committed
fix: matcher
1 parent 135cbab commit cc94123

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

packages/router/src/experimental/route-resolver/matchers/matcher-pattern.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -211,9 +211,17 @@ export class MatcherPatternPathDynamic<
211211
paramOptions = this.params[paramName]
212212
value = (paramOptions.set || identityFn)(params[paramName])
213213

214-
return Array.isArray(value)
215-
? value.map(encodeParam).join('/')
216-
: encodeParam(value)
214+
// param cannot be repeatable when in a sub segment
215+
if (__DEV__ && paramOptions.repeat) {
216+
warn(
217+
`Param "${String(paramName)}" is repeatable, but used in a sub segment of the path: "${this.pathParts.join('')}". Repeated params can only be used as a full path segment: "/file/[ids]+/something-else". This will break in production.`
218+
)
219+
return Array.isArray(value)
220+
? value.map(encodeParam).join('/')
221+
: encodeParam(value)
222+
}
223+
224+
return encodeParam(value as string | null | undefined)
217225
})
218226
.join('')
219227
}

0 commit comments

Comments
 (0)