Initial commit
This commit is contained in:
commit
78f8d225ee
21173 changed files with 2907774 additions and 0 deletions
43
node_modules/next/dist/shared/lib/router/utils/route-matcher.js
generated
vendored
Normal file
43
node_modules/next/dist/shared/lib/router/utils/route-matcher.js
generated
vendored
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
Object.defineProperty(exports, "getRouteMatcher", {
|
||||
enumerable: true,
|
||||
get: function() {
|
||||
return getRouteMatcher;
|
||||
}
|
||||
});
|
||||
const _utils = require("../../utils");
|
||||
function getRouteMatcher(param) {
|
||||
let { re, groups } = param;
|
||||
return (pathname)=>{
|
||||
const routeMatch = re.exec(pathname);
|
||||
if (!routeMatch) return false;
|
||||
const decode = (param)=>{
|
||||
try {
|
||||
return decodeURIComponent(param);
|
||||
} catch (e) {
|
||||
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;
|
||||
};
|
||||
}
|
||||
|
||||
//# sourceMappingURL=route-matcher.js.map
|
||||
Loading…
Add table
Add a link
Reference in a new issue