Add cleanup, minor fixes
This commit is contained in:
1 parent
97dc0a3570
commit
284e4e7080
7 files changed
+107
-15
No files matched your search
@@ -33,7 +33,7 @@ export default function AuthPage({ onAuthenticated }) {
|
||||
return (
|
||||
<div className="center-screen">
|
||||
<form className="card auth-card" onSubmit={submit}>
|
||||
<h1 className="brand-lg">goChat</h1>
|
||||
<h1 className="brand-lg">uPortal</h1>
|
||||
<div className="mode-switch">
|
||||
<button
|
||||
type="button"
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
import React, { useCallback, useEffect, useRef, useState } from 'react'
|
||||
import { api } from '../api.js'
|
||||
|
||||
function slugify(value) {
|
||||
// Room names are case-sensitive on the Jitsi side, so we only trim, collapse
|
||||
// disallowed characters into a dash, and strip leading/trailing dashes. Case is
|
||||
// preserved (e.g. "DailyStandup" stays "DailyStandup").
|
||||
function sanitizeRoomName(value) {
|
||||
return value
|
||||
.trim()
|
||||
.toLowerCase()
|
||||
.replace(/[^a-z0-9-_]+/g, '-')
|
||||
.replace(/[^a-zA-Z0-9-_]+/g, '-')
|
||||
.replace(/^-+|-+$/g, '')
|
||||
}
|
||||
|
||||
@@ -34,7 +36,7 @@ export default function RoomsPage({ room: routeRoom, onNavigate }) {
|
||||
}, [loadHistory])
|
||||
|
||||
const enter = useCallback(async (roomName) => {
|
||||
const target = slugify(roomName)
|
||||
const target = sanitizeRoomName(roomName)
|
||||
if (!target) {
|
||||
setError('Enter a room name')
|
||||
return
|
||||
@@ -59,7 +61,7 @@ export default function RoomsPage({ room: routeRoom, onNavigate }) {
|
||||
entered.current = null
|
||||
return
|
||||
}
|
||||
const target = slugify(routeRoom)
|
||||
const target = sanitizeRoomName(routeRoom)
|
||||
if (target && target !== entered.current) {
|
||||
entered.current = target
|
||||
enter(target)
|
||||
@@ -68,7 +70,7 @@ export default function RoomsPage({ room: routeRoom, onNavigate }) {
|
||||
|
||||
const submit = (event) => {
|
||||
event.preventDefault()
|
||||
const target = slugify(room)
|
||||
const target = sanitizeRoomName(room)
|
||||
if (!target) {
|
||||
setError('Enter a room name')
|
||||
return
|
||||
|
||||
Reference in new issue
Block a user