File tree Expand file tree Collapse file tree 1 file changed +9
-0
lines changed Expand file tree Collapse file tree 1 file changed +9
-0
lines changed Original file line number Diff line number Diff line change @@ -155,13 +155,22 @@ export function subst(template: string, params: ParamMap): string {
155155}
156156
157157function path ( template : string , params : ParamMap ) {
158+ // Fast path: if the template has no colons, no params to substitute
159+ if ( template . indexOf ( ':' ) === - 1 ) {
160+ return { renderedPath : template , remainingParams : params }
161+ }
162+
158163 const remainingParams = { ...params }
164+
159165 const renderedPath = template . replace ( / : [ _ A - Z a - z ] + \w * / g, ( p ) => {
160166 const key = p . slice ( 1 )
167+
161168 validatePathParam ( params , key )
169+
162170 delete remainingParams [ key ]
163171 return encodeURIComponent ( params [ key ] as string | number | boolean )
164172 } )
173+
165174 return { renderedPath, remainingParams }
166175}
167176
You can’t perform that action at this time.
0 commit comments