From fd1de297816c38bed1c73ade372a452def93afbe Mon Sep 17 00:00:00 2001 From: cha0s Date: Fri, 24 Jul 2020 07:49:27 -0500 Subject: [PATCH] fix: room case-insensitivity --- src/client/chat--leftRooms.scss | 1 + src/client/chat.jsx | 11 ++++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/client/chat--leftRooms.scss b/src/client/chat--leftRooms.scss index efc30a3..de5cd9a 100644 --- a/src/client/chat--leftRooms.scss +++ b/src/client/chat--leftRooms.scss @@ -25,6 +25,7 @@ .channels__joinText { flex-grow: 1; padding-left: 0.25em; + text-transform: lowercase; width: 0%; &:focus { font-size: 1.5em; diff --git a/src/client/chat.jsx b/src/client/chat.jsx index 7722611..bcdb71b 100644 --- a/src/client/chat.jsx +++ b/src/client/chat.jsx @@ -1,6 +1,6 @@ import './chat.scss'; -import {goBack, replace} from 'connected-react-router'; +import {goBack, push, replace} from 'connected-react-router'; import React, {useEffect, useRef} from 'react'; import {useSelector, useDispatch} from 'react-redux'; @@ -28,12 +28,17 @@ export default function Chat() { useEffect(() => { if (!allowedUser) { dispatch(historyLength > 1 ? goBack() : replace('/')); + return; + } + if (channel !== channel.toLowerCase()) { + dispatch(push(`/chat${channel.toLowerCase()}`)); + return; } if (!hasChannel && validateChannel(channel)) { - dispatch(submitJoin({channel, id: user.id})); + dispatch(submitJoin({channel: channel.toLowerCase(), id: user.id})); } }); - if (!allowedUser) { + if (!allowedUser || !hasChannel) { return null; } let origin;