From 1c8f7ec19fc40e98f5b1e042f68be8f864e1e1a0 Mon Sep 17 00:00:00 2001 From: 0x1eef <0x1eef@protonmail.com> Date: Mon, 23 Oct 2023 02:16:42 -0300 Subject: [PATCH] Append / to redirect path --- src/js/components/LanguageSelect.tsx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/js/components/LanguageSelect.tsx b/src/js/components/LanguageSelect.tsx index 52921cd69..7aa53d730 100644 --- a/src/js/components/LanguageSelect.tsx +++ b/src/js/components/LanguageSelect.tsx @@ -13,7 +13,14 @@ export function LanguageSelect({ locale, path = "" }: Props) { className="language" onChange={(el: JSX.Element) => { const locale = el.props.value; - location.replace(`/${locale}/${path}`); + const newPath = (() => { + if (path.endsWith("/") || path.length === 0) { + return path; + } else { + return `${path}/`; + } + })(); + location.replace(`/${locale}/${newPath}`); }} >