@vercel/routing-utils
Advanced tools
Comparing version 1.8.4-canary.2 to 1.8.4-canary.4
@@ -183,8 +183,8 @@ "use strict"; | ||
.filter(val => typeof val === 'string')); | ||
pathname = safelyCompile(pathname, indexes); | ||
hash = hash ? safelyCompile(hash, indexes) : null; | ||
pathname = safelyCompile(pathname, indexes, true); | ||
hash = hash ? safelyCompile(hash, indexes, true) : null; | ||
for (const [key, strOrArray] of Object.entries(query)) { | ||
let value = Array.isArray(strOrArray) ? strOrArray[0] : strOrArray; | ||
if (value) { | ||
value = safelyCompile(value, indexes); | ||
value = safelyCompile(value, indexes, true); | ||
} | ||
@@ -216,6 +216,17 @@ query[key] = value; | ||
} | ||
function safelyCompile(value, indexes) { | ||
function safelyCompile(value, indexes, attemptDirectCompile) { | ||
if (!value) { | ||
return value; | ||
} | ||
if (attemptDirectCompile) { | ||
try { | ||
// Attempt compiling normally with path-to-regexp first and fall back | ||
// to safely compiling to handle edge cases if path-to-regexp compile | ||
// fails | ||
return path_to_regexp_1.compile(value, { validate: false })(indexes); | ||
} | ||
catch (e) { | ||
// non-fatal, we continue to safely compile | ||
} | ||
} | ||
for (const key of Object.keys(indexes)) { | ||
@@ -222,0 +233,0 @@ if (value.includes(`:${key}`)) { |
{ | ||
"name": "@vercel/routing-utils", | ||
"version": "1.8.4-canary.2", | ||
"version": "1.8.4-canary.4", | ||
"description": "Vercel routing utilities", | ||
@@ -33,3 +33,3 @@ "main": "./dist/index.js", | ||
}, | ||
"gitHead": "2c239a6ee25ba0e29ccfb6462653a02ede48c82a" | ||
"gitHead": "db8e456603a6747da0c6e1327ec65488896de07f" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
48884
1108