Add checking to make sure received message is valid
This commit is contained in:
parent
fd95bd10b7
commit
71598b8d76
|
@ -17,7 +17,10 @@ app.get('/*', (req, res) => {
|
||||||
|
|
||||||
app.post('*', (req, res) => {
|
app.post('*', (req, res) => {
|
||||||
let id = req.path.substring(1);
|
let id = req.path.substring(1);
|
||||||
let message = Object.keys(req.body)[0];
|
let data = Object.keys(req.body)[0];
|
||||||
|
|
||||||
|
if (data && data.substring(0,2) === 'd:') {
|
||||||
|
let message = data.substring(2);
|
||||||
|
|
||||||
console.log("to: " + id);
|
console.log("to: " + id);
|
||||||
console.log(message);
|
console.log(message);
|
||||||
|
@ -25,6 +28,7 @@ app.post('*', (req, res) => {
|
||||||
io.in(id).emit('message', message);
|
io.in(id).emit('message', message);
|
||||||
|
|
||||||
res.end();
|
res.end();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const server = app.listen(port, 'localhost', (err) => {
|
const server = app.listen(port, 'localhost', (err) => {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user