use a set
parent
4c202e69f1
commit
7eac5a1ba0
|
|
@ -3,7 +3,7 @@ import * as configFunctions from "../helpers/functions.config.js";
|
||||||
import * as authenticationFunctions from "../helpers/functions.authentication.js";
|
import * as authenticationFunctions from "../helpers/functions.authentication.js";
|
||||||
import { useTestDatabases } from "../data/databasePaths.js";
|
import { useTestDatabases } from "../data/databasePaths.js";
|
||||||
export const router = Router();
|
export const router = Router();
|
||||||
const safeRedirects = [
|
const safeRedirects = new Set([
|
||||||
"/admin/fees",
|
"/admin/fees",
|
||||||
"/admin/occupancytypes",
|
"/admin/occupancytypes",
|
||||||
"/admin/tables",
|
"/admin/tables",
|
||||||
|
|
@ -16,14 +16,14 @@ const safeRedirects = [
|
||||||
"/workorders",
|
"/workorders",
|
||||||
"/workorders/new",
|
"/workorders/new",
|
||||||
"/reports"
|
"/reports"
|
||||||
];
|
]);
|
||||||
const getSafeRedirectURL = (possibleRedirectURL = "") => {
|
const getSafeRedirectURL = (possibleRedirectURL = "") => {
|
||||||
const urlPrefix = configFunctions.getProperty("reverseProxy.urlPrefix");
|
const urlPrefix = configFunctions.getProperty("reverseProxy.urlPrefix");
|
||||||
if (typeof possibleRedirectURL === "string") {
|
if (typeof possibleRedirectURL === "string") {
|
||||||
const urlToCheck = (possibleRedirectURL.startsWith(urlPrefix)
|
const urlToCheck = (possibleRedirectURL.startsWith(urlPrefix)
|
||||||
? possibleRedirectURL.slice(urlPrefix.length)
|
? possibleRedirectURL.slice(urlPrefix.length)
|
||||||
: possibleRedirectURL).toLowerCase();
|
: possibleRedirectURL).toLowerCase();
|
||||||
if (safeRedirects.includes(urlToCheck) ||
|
if (safeRedirects.has(urlToCheck) ||
|
||||||
/^(\/maps\/)\d+(\/edit)?$/.test(urlToCheck) ||
|
/^(\/maps\/)\d+(\/edit)?$/.test(urlToCheck) ||
|
||||||
/^(\/lots\/)\d+(\/edit)?$/.test(urlToCheck) ||
|
/^(\/lots\/)\d+(\/edit)?$/.test(urlToCheck) ||
|
||||||
/^(\/lotoccupancies\/)\d+(\/edit)?$/.test(urlToCheck) ||
|
/^(\/lotoccupancies\/)\d+(\/edit)?$/.test(urlToCheck) ||
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ import type * as recordTypes from "../types/recordTypes";
|
||||||
|
|
||||||
export const router = Router();
|
export const router = Router();
|
||||||
|
|
||||||
const safeRedirects = [
|
const safeRedirects = new Set([
|
||||||
"/admin/fees",
|
"/admin/fees",
|
||||||
"/admin/occupancytypes",
|
"/admin/occupancytypes",
|
||||||
"/admin/tables",
|
"/admin/tables",
|
||||||
|
|
@ -23,7 +23,7 @@ const safeRedirects = [
|
||||||
"/workorders",
|
"/workorders",
|
||||||
"/workorders/new",
|
"/workorders/new",
|
||||||
"/reports"
|
"/reports"
|
||||||
];
|
]);
|
||||||
|
|
||||||
const getSafeRedirectURL = (possibleRedirectURL = "") => {
|
const getSafeRedirectURL = (possibleRedirectURL = "") => {
|
||||||
const urlPrefix = configFunctions.getProperty("reverseProxy.urlPrefix");
|
const urlPrefix = configFunctions.getProperty("reverseProxy.urlPrefix");
|
||||||
|
|
@ -36,7 +36,7 @@ const getSafeRedirectURL = (possibleRedirectURL = "") => {
|
||||||
).toLowerCase();
|
).toLowerCase();
|
||||||
|
|
||||||
if (
|
if (
|
||||||
safeRedirects.includes(urlToCheck) ||
|
safeRedirects.has(urlToCheck) ||
|
||||||
/^(\/maps\/)\d+(\/edit)?$/.test(urlToCheck) ||
|
/^(\/maps\/)\d+(\/edit)?$/.test(urlToCheck) ||
|
||||||
/^(\/lots\/)\d+(\/edit)?$/.test(urlToCheck) ||
|
/^(\/lots\/)\d+(\/edit)?$/.test(urlToCheck) ||
|
||||||
/^(\/lotoccupancies\/)\d+(\/edit)?$/.test(urlToCheck) ||
|
/^(\/lotoccupancies\/)\d+(\/edit)?$/.test(urlToCheck) ||
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue