From bbcc64af6b8e610f09a845c940c930d4d91a12f4 Mon Sep 17 00:00:00 2001 From: Wu Cheng-Han Date: Sun, 12 Jul 2015 17:19:07 +0800 Subject: [PATCH] Handle an server getNotenameFromSocket referer undefined exception --- lib/realtime.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/realtime.js b/lib/realtime.js index 66a3c9c5..3e367158 100644 --- a/lib/realtime.js +++ b/lib/realtime.js @@ -151,7 +151,11 @@ function getStatus(callback) { } 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]; if (notename == config.featuresnotename) { return notename;