From 18252fb9a8d1ffd5082fc756d9da1083137b0f86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Mon, 20 Sep 2021 10:41:26 -0400 Subject: [PATCH] refactor: no regex --- src/controllers/helpers.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/controllers/helpers.js b/src/controllers/helpers.js index 52839728e3..6173402c47 100644 --- a/src/controllers/helpers.js +++ b/src/controllers/helpers.js @@ -122,8 +122,7 @@ helpers.notAllowed = async function (req, res, error) { if (req.loggedIn || req.uid === -1) { if (res.locals.isAPI) { - const cleanedUrl = req.originalUrl.replace(new RegExp(`^${relative_path}`), ''); - if (cleanedUrl.startsWith('/api/v3')) { + if (req.originalUrl.startsWith(`${relative_path}/api/v3`)) { helpers.formatApiResponse(403, res, error); } else { res.status(403).json({