Some checks failed
CI / go (push) Waiting to run
CI / docker (push) Waiting to run
CI / lint-go (push) Waiting to run
CI / lint-docs (push) Waiting to run
CI / check-paperclip (push) Waiting to run
Deploy static site / Deploy to GitHub Pages (push) Has been cancelled
Deploy static site / Deploy via Docker to hatch.surf (push) Has been cancelled
Resolved conflicts by taking GitHub versions for: - .dockerignore, .gitignore, Dockerfile, README.md, docker-compose.yml Kept deploy.sh updated to: - Pull from GitHub (primary source) - Push to Gitea (push-mirror) - Build from site/ directory (GitHub structure) Co-Authored-By: Paperclip <noreply@paperclip.ing>
45 lines
1.4 KiB
JavaScript
45 lines
1.4 KiB
JavaScript
"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
|