From 962ec27df424f1029f769ca37e016179ff692418 Mon Sep 17 00:00:00 2001 From: Cabeza Date: Mon, 10 Jun 2024 05:01:08 -0400 Subject: [PATCH] chore: sanitize appUrl to remove trailing slash in updateConfigVariable function (#496) --- frontend/src/pages/admin/config/[category].tsx | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/frontend/src/pages/admin/config/[category].tsx b/frontend/src/pages/admin/config/[category].tsx index cafd0ea8..23b64b86 100644 --- a/frontend/src/pages/admin/config/[category].tsx +++ b/frontend/src/pages/admin/config/[category].tsx @@ -72,6 +72,10 @@ export default function AppShellDemo() { }; const updateConfigVariable = (configVariable: UpdateConfig) => { + if (configVariable.key === 'general.appUrl') { + configVariable.value = sanitizeUrl(configVariable.value); + } + const index = updatedConfigVariables.findIndex( (item) => item.key === configVariable.key, ); @@ -86,6 +90,10 @@ export default function AppShellDemo() { } }; + const sanitizeUrl = (url: string): string => { + return url.endsWith('/') ? url.slice(0, -1) : url; + }; + useEffect(() => { configService.getByCategory(categoryId).then((configVariables) => { setConfigVariables(configVariables);