server handles bad routing / params now

This commit is contained in:
ian ramzy 2020-03-31 17:07:03 -04:00
parent 5df20e1b4c
commit 510d11b457
2 changed files with 16 additions and 12 deletions

View File

@ -663,16 +663,6 @@ pipVideo.addEventListener("leavepictureinpicture", () => {
//
function startUp() {
// strip url parameters
if (url.indexOf("?") > -1) {
window.location.href = url.split("?")[0];
}
// if no chat room provided go back to newroom
if (window.location.pathname === "/room") {
window.location.href = "/landing/newroom";
}
// Redirect unsupported browsers
if (
!isWebRTCSupported ||

View File

@ -10,6 +10,7 @@ var http = require("http").createServer(app);
var io = require("socket.io")(http);
var path = require("path");
var public = path.join(__dirname, "public");
const url = require("url"); // built-in utility
// enable ssl redirect
app.use(sslRedirect());
@ -22,14 +23,27 @@ app.get("/newroom", function (req, res) {
res.sendFile(path.join(public, "newroom.html"));
});
app.get("/room/", function (req, res) {
res.redirect("/");
});
app.get("/room/*", function (req, res) {
res.sendFile(path.join(public, "chat.html"));
if (Object.keys(req.query).length > 0) {
logIt("redirect:" + req.url + " to " + url.parse(req.url).pathname);
res.redirect(url.parse(req.url).pathname);
} else {
res.sendFile(path.join(public, "chat.html"));
}
});
app.use(express.static("public"));
function logIt(msg, room) {
console.log(room + ": " + msg);
if (room) {
console.log(room + ": " + msg);
} else {
console.log(msg);
}
}
// When a socket connects, set up the specific listeners we will use.