We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
path
1 parent 29150df commit 6a15092Copy full SHA for 6a15092
src/index.ts
@@ -154,10 +154,13 @@ export function subst(template: string, params: ParamMap): string {
154
return renderedPath
155
}
156
157
+// Pre-compile regex for better performance - avoids recompilation overhead on each call
158
+const PATH_PARAM_REGEX = /:[_A-Za-z]+\w*/g
159
+
160
function path(template: string, params: ParamMap) {
161
const remainingParams = { ...params }
162
- const renderedPath = template.replace(/:[_A-Za-z]+\w*/g, (p) => {
163
+ const renderedPath = template.replace(PATH_PARAM_REGEX, (p) => {
164
const key = p.slice(1)
165
166
validatePathParam(params, key)
0 commit comments