From 3be06d6684cf07bb3de21888fe6c05b675296773 Mon Sep 17 00:00:00 2001 From: Feross Aboukhadijeh Date: Fri, 22 May 2015 16:21:55 +0200 Subject: [PATCH] always produce valid urls with trailing / Fixes this error: ERROR: connection error to wss://tracker.webtorrent.io?1fe16837ed ERROR: If you think this is a bug in webtorrent, report it! --- lib/websocket-tracker.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/websocket-tracker.js b/lib/websocket-tracker.js index 59a8f94..f7ba1f3 100644 --- a/lib/websocket-tracker.js +++ b/lib/websocket-tracker.js @@ -25,7 +25,11 @@ function WebSocketTracker (client, announceUrl, opts) { self.destroyed = false self._opts = opts + self._announceUrl = announceUrl + if (self._announceUrl[self._announceUrl.length - 1] !== '/') self._announceUrl += '/' + self._announceUrl += '?' + hat(40) + self._peers = {} // peers (offer id -> peer) self._socket = null self._intervalMs = self.client._intervalMs // use client interval initially @@ -98,7 +102,7 @@ WebSocketTracker.prototype._openSocket = function () { self._onSocketDataBound = self._onSocketData.bind(self) self._onSocketCloseBound = self._onSocketClose.bind(self) - self._socket = new Socket(self._announceUrl + '?' + hat(40)) + self._socket = new Socket(self._announceUrl) self._socket.on('data', self._onSocketDataBound) self._socket.on('close', self._onSocketCloseBound) self._socket.on('error', self._onSocketErrorBound)