Skip to content

Commit eb167b1

Browse files
committed
Remove trailing slash
1 parent 6b07b7d commit eb167b1

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/components/app.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,17 @@ import Header from './header';
1313
import Footer from './footer';
1414

1515
const App: FunctionalComponent = () => {
16+
function removeTrailingSlash({ url }: { url: string }) {
17+
if (!window) return;
18+
if (url.slice(-1) === '/') {
19+
window.history.replaceState(null, '', url.slice(0, -1));
20+
}
21+
};
22+
1623
return (
1724
<div id="preact_root">
1825
<Header />
19-
<Router>
26+
<Router onChange={removeTrailingSlash}>
2027
<Home path="/" />
2128
<AboutUs path="/about-us" />
2229
<Canteen path="/canteen" />

0 commit comments

Comments
 (0)