Handle an server getNotenameFromSocket referer undefined exception

This commit is contained in:
Wu Cheng-Han 2015-07-12 17:19:07 +08:00
parent f359044776
commit bbcc64af6b

View file

@ -151,7 +151,11 @@ function getStatus(callback) {
} }
function getNotenameFromSocket(socket) { function getNotenameFromSocket(socket) {
var hostUrl = url.parse(socket.handshake.headers.referer); var referer = socket.handshake.headers.referer;
if (!referer) {
return socket.disconnect();
}
var hostUrl = url.parse(referer);
var notename = hostUrl.pathname.split('/')[1]; var notename = hostUrl.pathname.split('/')[1];
if (notename == config.featuresnotename) { if (notename == config.featuresnotename) {
return notename; return notename;