mirror of
https://github.com/darkwire/darkwire.io.git
synced 2025-07-22 12:50:30 +00:00
Strip names on creation as well
This commit is contained in:
parent
5caef507ce
commit
c1be6300ad
@ -37,10 +37,7 @@ function generateNewRoom(req, res, id) {
|
|||||||
return res.redirect(`/${id}`);
|
return res.redirect(`/${id}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
app.get('/', (req, res) => generateNewRoom(req, res, shortid.generate()));
|
function stripName(name) {
|
||||||
|
|
||||||
app.get('/:roomId', (req, res) => {
|
|
||||||
const stripName = (name) => {
|
|
||||||
const chatName = name.toLowerCase().replace(/[^A-Za-z0-9]/g, '-');
|
const chatName = name.toLowerCase().replace(/[^A-Za-z0-9]/g, '-');
|
||||||
if (chatName.length >= 50) {
|
if (chatName.length >= 50) {
|
||||||
return chatName.substr(0, 50);
|
return chatName.substr(0, 50);
|
||||||
@ -49,6 +46,10 @@ app.get('/:roomId', (req, res) => {
|
|||||||
return chatName;
|
return chatName;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
app.get('/', (req, res) => generateNewRoom(req, res, stripName(shortid.generate())));
|
||||||
|
|
||||||
|
app.get('/:roomId', (req, res) => {
|
||||||
const roomId = stripName(req.params.roomId) || false;
|
const roomId = stripName(req.params.roomId) || false;
|
||||||
|
|
||||||
let roomExists = _.findWhere(rooms, {_id: roomId}) || false;
|
let roomExists = _.findWhere(rooms, {_id: roomId}) || false;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user