2022-09-14 07:54:56 +00:00
|
|
|
import { getBackendSafeRoomName } from '../util/uri';
|
2019-10-04 07:31:22 +00:00
|
|
|
|
2017-05-04 15:20:41 +00:00
|
|
|
/**
|
|
|
|
* Builds and returns the room name.
|
|
|
|
*
|
|
|
|
* @returns {string}
|
|
|
|
*/
|
2022-09-14 07:54:56 +00:00
|
|
|
export default function getRoomName(): string | undefined {
|
2017-05-04 15:20:41 +00:00
|
|
|
const path = window.location.pathname;
|
|
|
|
|
2019-10-09 12:35:09 +00:00
|
|
|
// The last non-directory component of the path (name) is the room.
|
|
|
|
const roomName = path.substring(path.lastIndexOf('/') + 1) || undefined;
|
2017-05-04 15:20:41 +00:00
|
|
|
|
2019-10-04 07:31:22 +00:00
|
|
|
return getBackendSafeRoomName(roomName);
|
2017-05-04 15:20:41 +00:00
|
|
|
}
|