bpms_site/.svn/pristine/26/260f5a38bc12aa94bf2f5351c96ae0442ede4499.svn-base
2025-11-02 16:38:49 +03:30

23 lines
828 B
Plaintext

import { PERMANENT_REDIRECT_STATUS, TEMPORARY_REDIRECT_STATUS } from "../shared/lib/constants";
export const allowedStatusCodes = new Set([
301,
302,
303,
307,
308
]);
export function getRedirectStatus(route) {
return route.statusCode || (route.permanent ? PERMANENT_REDIRECT_STATUS : TEMPORARY_REDIRECT_STATUS);
}
// for redirects we restrict matching /_next and for all routes
// we add an optional trailing slash at the end for easier
// configuring between trailingSlash: true/false
export function modifyRouteRegex(regex, restrictedPaths) {
if (restrictedPaths) {
regex = regex.replace(/\^/, `^(?!${restrictedPaths.map((path)=>path.replace(/\//g, "\\/")).join("|")})`);
}
regex = regex.replace(/\$$/, "(?:\\/)?$");
return regex;
}
//# sourceMappingURL=redirect-status.js.map