mirror of
https://github.com/bitsocialnet/5chan.git
synced 2026-08-03 07:41:04 +02:00
fix(router): a link could include '%23' instead of '#'
This commit is contained in:
+12
-1
@@ -1,5 +1,5 @@
|
|||||||
import { useEffect, useState } from 'react';
|
import { useEffect, useState } from 'react';
|
||||||
import { Outlet, Route, Routes, useLocation, useParams } from 'react-router-dom';
|
import { Outlet, Route, Routes, useLocation, useNavigate, useParams } from 'react-router-dom';
|
||||||
import { useAccountComment } from '@plebbit/plebbit-react-hooks';
|
import { useAccountComment } from '@plebbit/plebbit-react-hooks';
|
||||||
import { isAllView, isSubscriptionsView } from './lib/utils/view-utils';
|
import { isAllView, isSubscriptionsView } from './lib/utils/view-utils';
|
||||||
import useIsMobile from './hooks/use-is-mobile';
|
import useIsMobile from './hooks/use-is-mobile';
|
||||||
@@ -90,6 +90,17 @@ const GlobalLayout = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const App = () => {
|
const App = () => {
|
||||||
|
// react router doesn't handle the %23 hash correctly, so we need to replace it with #
|
||||||
|
const navigate = useNavigate();
|
||||||
|
const location = useLocation();
|
||||||
|
useEffect(() => {
|
||||||
|
const currentPath = location.pathname + location.hash;
|
||||||
|
if (currentPath.includes('%23')) {
|
||||||
|
const correctedPath = currentPath.replace('%23', '#');
|
||||||
|
navigate(correctedPath, { replace: true });
|
||||||
|
}
|
||||||
|
}, [location, navigate]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={styles.app}>
|
<div className={styles.app}>
|
||||||
<Routes>
|
<Routes>
|
||||||
|
|||||||
Reference in New Issue
Block a user