forked from snxraven/LinkUp-P2P-Chat
topic validation for the join box
This commit is contained in:
parent
ff0acb1a85
commit
50a02e8dfd
10
app.js
10
app.js
@ -369,7 +369,15 @@ async function createChatRoom() {
|
|||||||
|
|
||||||
async function joinChatRoom(e) {
|
async function joinChatRoom(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
const topicStr = document.querySelector('#join-chat-room-topic').value;
|
const topicStr = document.querySelector('#join-chat-room-topic').value.trim();
|
||||||
|
|
||||||
|
// Validate the topic string
|
||||||
|
const isValidTopic = /^[0-9a-fA-F]{64}$/.test(topicStr);
|
||||||
|
if (!isValidTopic) {
|
||||||
|
alert('Invalid topic format. Please enter a 64-character hexadecimal string.');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const topicBuffer = b4a.from(topicStr, 'hex');
|
const topicBuffer = b4a.from(topicStr, 'hex');
|
||||||
addRoomToList(topicStr);
|
addRoomToList(topicStr);
|
||||||
await joinSwarm(topicBuffer);
|
await joinSwarm(topicBuffer);
|
||||||
|
Loading…
Reference in New Issue
Block a user