Skip to content

Commit

Permalink
correct redirect
Browse files Browse the repository at this point in the history
  • Loading branch information
pepite committed Sep 4, 2024
1 parent 7850cac commit 56bc9ec
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/components/Language/Language.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import i18n from '../../i18n';
//import { useTranslation } from 'react-i18next';
import { redirect } from 'react-router-dom';
import { redirect, redirectDocument, replace } from 'react-router-dom';

import "./Language.scss";

Expand All @@ -20,14 +20,13 @@ const Language: React.FC<LanguageProps> = ({ changeLanguage }) => {

const currentPath = window.location.href;
let newUrl = '';

if (lng === 'en') {
newUrl = currentPath.replace('\.fr', '\.com');
newUrl = currentPath.replace('\.fr', '.com');
} else {
newUrl = currentPath.replace('\.com', '\.fr');
newUrl = currentPath.replace('\.com', '.fr');
}

redirect(newUrl);
window.location.href = newUrl;
};

return (
Expand Down

0 comments on commit 56bc9ec

Please sign in to comment.