Spaces:
Running
Running
File size: 1,483 Bytes
c592d77 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | "use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "getRouteMatcher", {
enumerable: true,
get: function() {
return getRouteMatcher;
}
});
const _utils = require("../../utils");
const _routematchutils = require("./route-match-utils");
function getRouteMatcher({ re, groups }) {
const rawMatcher = (pathname)=>{
const routeMatch = re.exec(pathname);
if (!routeMatch) return false;
const decode = (param)=>{
try {
return decodeURIComponent(param);
} catch {
throw Object.defineProperty(new _utils.DecodeError('failed to decode param'), "__NEXT_ERROR_CODE", {
value: "E528",
enumerable: false,
configurable: true
});
}
};
const params = {};
for (const [key, group] of Object.entries(groups)){
const match = routeMatch[group.pos];
if (match !== undefined) {
if (group.repeat) {
params[key] = match.split('/').map((entry)=>decode(entry));
} else {
params[key] = decode(match);
}
}
}
return params;
};
// Wrap with safe matcher to handle parameter cleaning
return (0, _routematchutils.safeRouteMatcher)(rawMatcher);
}
//# sourceMappingURL=route-matcher.js.map |