@vercel/routing-utils
Advanced tools
Comparing version 1.8.4-canary.0 to 1.8.4-canary.1
@@ -168,3 +168,17 @@ "use strict"; | ||
}); | ||
let destParams = new Set(); | ||
if (destination.includes(':') && segments.length > 0) { | ||
const pathnameKeys = []; | ||
const hashKeys = []; | ||
try { | ||
path_to_regexp_1.pathToRegexp(pathname, pathnameKeys); | ||
path_to_regexp_1.pathToRegexp(hash || '', hashKeys); | ||
} | ||
catch (_) { | ||
// this is not fatal so don't error when failing to parse the | ||
// params from the destination | ||
} | ||
destParams = new Set([...pathnameKeys, ...hashKeys] | ||
.map(key => key.name) | ||
.filter(val => typeof val === 'string')); | ||
pathname = safelyCompile(pathname, indexes); | ||
@@ -181,7 +195,9 @@ hash = hash ? safelyCompile(hash, indexes) : null; | ||
// We only add path segments to redirect queries if manually | ||
// specified | ||
if (!isRedirect) { | ||
for (const [name, value] of Object.entries(indexes)) { | ||
if (!(name in query) && name !== UN_NAMED_SEGMENT) { | ||
query[name] = value; | ||
// specified and only automatically add them for rewrites if one | ||
// or more params aren't already used in the destination's path | ||
const paramKeys = Object.keys(indexes); | ||
if (!isRedirect && !paramKeys.some(param => destParams.has(param))) { | ||
for (const param of paramKeys) { | ||
if (!(param in query) && param !== UN_NAMED_SEGMENT) { | ||
query[param] = indexes[param]; | ||
} | ||
@@ -188,0 +204,0 @@ } |
{ | ||
"name": "@vercel/routing-utils", | ||
"version": "1.8.4-canary.0", | ||
"version": "1.8.4-canary.1", | ||
"description": "Vercel routing utilities", | ||
@@ -33,3 +33,3 @@ "main": "./dist/index.js", | ||
}, | ||
"gitHead": "d416f70a6e84549be896f0f2450fccd07007803e" | ||
"gitHead": "175f302a7fe7c373ebbee0e82c8e23e7deb44f1b" | ||
} |
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
48429
1097