Skip to content

Commit f7fd63d

Browse files
Remove trailing slash if one is present
Closes pterodactyl#2386
1 parent 08dcb85 commit f7fd63d

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

resources/scripts/routers/AuthenticationRouter.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React, { useEffect } from 'react';
22
import ReactGA from 'react-ga';
3-
import { Route, RouteComponentProps, Switch } from 'react-router-dom';
3+
import { Route, RouteComponentProps, Switch, Redirect } from 'react-router-dom';
44
import LoginContainer from '@/components/auth/LoginContainer';
55
import ForgotPasswordContainer from '@/components/auth/ForgotPasswordContainer';
66
import ResetPasswordContainer from '@/components/auth/ResetPasswordContainer';
@@ -15,6 +15,7 @@ export default ({ location, history, match }: RouteComponentProps) => {
1515
return (
1616
<div className={'pt-8 xl:pt-32'}>
1717
<Switch location={location}>
18+
<Redirect from="/:url*(/+)" to={location.pathname.slice(0, -1)} />
1819
<Route path={`${match.path}/login`} component={LoginContainer} exact/>
1920
<Route path={`${match.path}/login/checkpoint`} component={LoginCheckpointContainer}/>
2021
<Route path={`${match.path}/password`} component={ForgotPasswordContainer} exact/>

resources/scripts/routers/DashboardRouter.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React, { useEffect } from 'react';
22
import ReactGA from 'react-ga';
3-
import { NavLink, Route, RouteComponentProps, Switch } from 'react-router-dom';
3+
import { NavLink, Route, RouteComponentProps, Switch, Redirect } from 'react-router-dom';
44
import AccountOverviewContainer from '@/components/dashboard/AccountOverviewContainer';
55
import NavigationBar from '@/components/NavigationBar';
66
import DashboardContainer from '@/components/dashboard/DashboardContainer';
@@ -27,6 +27,7 @@ export default ({ location }: RouteComponentProps) => {
2727
}
2828
<TransitionRouter>
2929
<Switch location={location}>
30+
<Redirect from="/:url*(/+)" to={location.pathname.slice(0, -1)} />
3031
<Route path={'/'} component={DashboardContainer} exact />
3132
<Route path={'/account'} component={AccountOverviewContainer} exact/>
3233
<Route path={'/account/api'} component={AccountApiContainer} exact/>

resources/scripts/routers/ServerRouter.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React, { useEffect, useState } from 'react';
22
import ReactGA from 'react-ga';
3-
import { NavLink, Route, RouteComponentProps, Switch } from 'react-router-dom';
3+
import { NavLink, Route, RouteComponentProps, Switch, Redirect } from 'react-router-dom';
44
import NavigationBar from '@/components/NavigationBar';
55
import ServerConsole from '@/components/server/ServerConsole';
66
import TransitionRouter from '@/TransitionRouter';
@@ -123,6 +123,7 @@ const ServerRouter = ({ match, location }: RouteComponentProps<{ id: string }>)
123123
<>
124124
<TransitionRouter>
125125
<Switch location={location}>
126+
<Redirect from="/:url*(/+)" to={location.pathname.slice(0, -1)} />
126127
<Route path={`${match.path}`} component={ServerConsole} exact/>
127128
<Route
128129
path={`${match.path}/files`}

0 commit comments

Comments
 (0)