Initial boiler plate project
This commit is contained in:
40
node_modules/next/dist/shared/lib/router/utils/route-matcher.js
generated
vendored
Normal file
40
node_modules/next/dist/shared/lib/router/utils/route-matcher.js
generated
vendored
Normal file
@ -0,0 +1,40 @@
|
||||
"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 (_) {
|
||||
throw new _utils.DecodeError("failed to decode param");
|
||||
}
|
||||
};
|
||||
const params = {};
|
||||
Object.keys(groups).forEach((slugName)=>{
|
||||
const g = groups[slugName];
|
||||
const m = routeMatch[g.pos];
|
||||
if (m !== undefined) {
|
||||
params[slugName] = ~m.indexOf("/") ? m.split("/").map((entry)=>decode(entry)) : g.repeat ? [
|
||||
decode(m)
|
||||
] : decode(m);
|
||||
}
|
||||
});
|
||||
return params;
|
||||
};
|
||||
}
|
||||
|
||||
//# sourceMappingURL=route-matcher.js.map
|
||||
Reference in New Issue
Block a user