summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorChristoph (Sheogorath) Kern2018-02-05 14:50:47 +0100
committerGitHub2018-02-05 14:50:47 +0100
commitf3358b49f513c630e01357948be8591eb6e4d319 (patch)
tree5e099dfcdd07c8f64f2968f0ca1b1205841a6b9a /lib
parent20242622004edc2438ecb6f59feab0b9eddc6280 (diff)
parentc4f8fb78eeef1c9536caae4c8cced4f0f50f1932 (diff)
Merge pull request #716 from stbuehler/fix-referer
don't require referer to find note id in socket.io connections (fixes #623)
Diffstat (limited to 'lib')
-rw-r--r--lib/realtime.js20
1 files changed, 14 insertions, 6 deletions
diff --git a/lib/realtime.js b/lib/realtime.js
index c731e5b0..d6ba62b2 100644
--- a/lib/realtime.js
+++ b/lib/realtime.js
@@ -272,16 +272,24 @@ function isReady () {
}
function extractNoteIdFromSocket (socket) {
- if (!socket || !socket.handshake || !socket.handshake.headers) {
+ if (!socket || !socket.handshake) {
return false
}
- var referer = socket.handshake.headers.referer
- if (!referer) {
+ if (socket.handshake.query && socket.handshake.query.noteId) {
+ return socket.handshake.query.noteId
+ } else if (socket.handshake.headers) {
+ // this part is only for backward compatibility only; current code
+ // should be using noteId query parameter instead.
+ var referer = socket.handshake.headers.referer
+ if (!referer) {
+ return false
+ }
+ var hostUrl = url.parse(referer)
+ var noteId = config.urlpath ? hostUrl.pathname.slice(config.urlpath.length + 1, hostUrl.pathname.length).split('/')[1] : hostUrl.pathname.split('/')[1]
+ return noteId
+ } else {
return false
}
- var hostUrl = url.parse(referer)
- var noteId = config.urlpath ? hostUrl.pathname.slice(config.urlpath.length + 1, hostUrl.pathname.length).split('/')[1] : hostUrl.pathname.split('/')[1]
- return noteId
}
function parseNoteIdFromSocket (socket, callback) {