@paroicms/server
Version:
The ParoiCMS server
16 lines • 568 B
JavaScript
export function createRedirectUrl(req, entry) {
const { originalUrl } = req;
let mappedPath;
if (entry.mapPaths) {
for (const [fromRegex, toPath] of Object.entries(entry.mapPaths)) {
const regex = new RegExp(fromRegex);
if (regex.test(originalUrl)) {
mappedPath = originalUrl.replace(regex, toPath);
break;
}
}
}
const path = mappedPath ?? (entry.preservePath ? originalUrl : "");
return `${entry.to}${path}`;
}
//# sourceMappingURL=http-redirection-url.js.map