Skip to content

Commit

Permalink
Append / to redirect path
Browse files Browse the repository at this point in the history
  • Loading branch information
0x1eef committed Oct 23, 2023
1 parent 223a163 commit 1c8f7ec
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/js/components/LanguageSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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}`);
}}
>
<option value="ar">عربي</option>
Expand Down

0 comments on commit 1c8f7ec

Please sign in to comment.