Skip to content

Commit

Permalink
fix error with trailing slash (#5522)
Browse files Browse the repository at this point in the history
* fix error with trailing slash

* eslint

* eslint again
  • Loading branch information
farhatahmad authored Nov 15, 2023
1 parent 0bbd9e2 commit c8b70d1
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions app/javascript/routes/AuthenticatedOnly.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@
// with Greenlight; if not, see <http://www.gnu.org/licenses/>.

import React from 'react';
import {
Navigate, Outlet, useLocation, useMatch,
} from 'react-router-dom';
import { Navigate, Outlet, useMatch } from 'react-router-dom';
import { useTranslation } from 'react-i18next';
import { toast } from 'react-toastify';
import { useAuth } from '../contexts/auth/AuthProvider';
Expand All @@ -26,7 +24,6 @@ import useDeleteSession from '../hooks/mutations/sessions/useDeleteSession';
export default function AuthenticatedOnly() {
const { t } = useTranslation();
const currentUser = useAuth();
const location = useLocation();
const roomsMatch = useMatch('/rooms/:friendlyId');
const superAdminMatch = useMatch('/admin/*');
const deleteSession = useDeleteSession({ showToast: false });
Expand All @@ -46,7 +43,7 @@ export default function AuthenticatedOnly() {

// Custom logic to redirect from Rooms page to join page if the user isn't signed in
if (!currentUser.signed_in && roomsMatch) {
return <Navigate to={`${location.pathname}/join`} />;
return <Navigate to={`${roomsMatch.pathnameBase}/join`} />;
}

if (currentUser.signed_in && currentUser.isSuperAdmin && !superAdminMatch) {
Expand Down

0 comments on commit c8b70d1

Please sign in to comment.