Add checking to make sure received message is valid

This commit is contained in:
Tanner Collin 2016-12-24 15:27:38 -07:00
parent fd95bd10b7
commit 71598b8d76

View File

@ -17,7 +17,10 @@ app.get('/*', (req, res) => {
app.post('*', (req, res) => {
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(message);
@ -25,6 +28,7 @@ app.post('*', (req, res) => {
io.in(id).emit('message', message);
res.end();
}
});
const server = app.listen(port, 'localhost', (err) => {