diff --git a/client.js b/client.js index f8888eb..671f134 100644 --- a/client.js +++ b/client.js @@ -62,7 +62,7 @@ class Client extends EventEmitter { this._wrtc = typeof opts.wrtc === 'function' ? opts.wrtc() : opts.wrtc let announce = typeof opts.announce === 'string' - ? [ opts.announce ] + ? [opts.announce] : opts.announce == null ? [] : opts.announce // Remove trailing slash from trackers to catch duplicates diff --git a/lib/client/udp-tracker.js b/lib/client/udp-tracker.js index 99ee5b9..4923ce1 100644 --- a/lib/client/udp-tracker.js +++ b/lib/client/udp-tracker.js @@ -176,7 +176,7 @@ class UDPTracker extends Tracker { } const infoHashes = (Array.isArray(opts.infoHash) && opts.infoHash.length > 0) ? opts.infoHash.map(infoHash => { return infoHash.toString('hex') }) - : [ (opts.infoHash && opts.infoHash.toString('hex')) || self.client.infoHash ] + : [(opts.infoHash && opts.infoHash.toString('hex')) || self.client.infoHash] for (let i = 0, len = (msg.length - 8) / 12; i < len; i += 1) { self.client.emit('scrape', { diff --git a/lib/common-node.js b/lib/common-node.js index b06d000..bfa547f 100644 --- a/lib/common-node.js +++ b/lib/common-node.js @@ -10,7 +10,7 @@ exports.IPV4_RE = /^[\d.]+$/ exports.IPV6_RE = /^[\da-fA-F:]+$/ exports.REMOVE_IPV4_MAPPED_IPV6_RE = /^::ffff:/ -exports.CONNECTION_ID = Buffer.concat([ toUInt32(0x417), toUInt32(0x27101980) ]) +exports.CONNECTION_ID = Buffer.concat([toUInt32(0x417), toUInt32(0x27101980)]) exports.ACTIONS = { CONNECT: 0, ANNOUNCE: 1, SCRAPE: 2, ERROR: 3 } exports.EVENTS = { update: 0, completed: 1, started: 2, stopped: 3 } exports.EVENT_IDS = { diff --git a/lib/server/parse-http.js b/lib/server/parse-http.js index bf6cb2c..85a1c87 100644 --- a/lib/server/parse-http.js +++ b/lib/server/parse-http.js @@ -42,7 +42,7 @@ function parseHttpRequest (req, opts) { } else if (opts.action === 'scrape' || s[0] === '/scrape') { params.action = common.ACTIONS.SCRAPE - if (typeof params.info_hash === 'string') params.info_hash = [ params.info_hash ] + if (typeof params.info_hash === 'string') params.info_hash = [params.info_hash] if (Array.isArray(params.info_hash)) { params.info_hash = params.info_hash.map(function (binaryInfoHash) { if (typeof binaryInfoHash !== 'string' || binaryInfoHash.length !== 20) { diff --git a/lib/server/parse-websocket.js b/lib/server/parse-websocket.js index ec4e606..4416008 100644 --- a/lib/server/parse-websocket.js +++ b/lib/server/parse-websocket.js @@ -39,7 +39,7 @@ function parseWebSocketRequest (socket, opts, params) { } else if (params.action === 'scrape') { params.action = common.ACTIONS.SCRAPE - if (typeof params.info_hash === 'string') params.info_hash = [ params.info_hash ] + if (typeof params.info_hash === 'string') params.info_hash = [params.info_hash] if (Array.isArray(params.info_hash)) { params.info_hash = params.info_hash.map(function (binaryInfoHash) { if (typeof binaryInfoHash !== 'string' || binaryInfoHash.length !== 20) { diff --git a/test/client.js b/test/client.js index 1d38986..569ccbe 100644 --- a/test/client.js +++ b/test/client.js @@ -357,7 +357,7 @@ function testClientAnnounceWithNumWant (t, serverType) { common.createServer(t, serverType, function (server, announceUrl) { var client1 = new Client({ infoHash: fixtures.leaves.parsedTorrent.infoHash, - announce: [ announceUrl ], + announce: [announceUrl], peerId: peerId1, port: port, wrtc: {} diff --git a/test/evict.js b/test/evict.js index 1ff60bb..1a09033 100644 --- a/test/evict.js +++ b/test/evict.js @@ -31,7 +31,7 @@ function serverTest (t, serverType, serverFamily) { var client1 = new Client({ infoHash: infoHash, - announce: [ announceUrl ], + announce: [announceUrl], peerId: peerId, port: 6881, wrtc: wrtc @@ -43,7 +43,7 @@ function serverTest (t, serverType, serverFamily) { client1.once('update', function (data) { var client2 = new Client({ infoHash: infoHash, - announce: [ announceUrl ], + announce: [announceUrl], peerId: peerId2, port: 6882, wrtc: wrtc @@ -68,7 +68,7 @@ function serverTest (t, serverType, serverFamily) { var client3 = new Client({ infoHash: infoHash, - announce: [ announceUrl ], + announce: [announceUrl], peerId: peerId3, port: 6880, wrtc: wrtc diff --git a/test/scrape.js b/test/scrape.js index 6391449..85b7e73 100644 --- a/test/scrape.js +++ b/test/scrape.js @@ -119,7 +119,7 @@ function clientScrapeMulti (t, serverType) { commonTest.createServer(t, serverType, function (server, announceUrl) { Client.scrape({ - infoHash: [ infoHash1, infoHash2 ], + infoHash: [infoHash1, infoHash2], announce: announceUrl }, function (err, results) { t.error(err) @@ -161,7 +161,7 @@ test('server: multiple info_hash scrape (manual http request)', function (t) { var scrapeUrl = announceUrl.replace('/announce', '/scrape') var url = scrapeUrl + '?' + commonLib.querystringStringify({ - info_hash: [ binaryInfoHash1, binaryInfoHash2 ] + info_hash: [binaryInfoHash1, binaryInfoHash2] }) get.concat(url, function (err, res, data) { diff --git a/test/server.js b/test/server.js index 73e9fe6..c9371bb 100644 --- a/test/server.js +++ b/test/server.js @@ -33,7 +33,7 @@ function serverTest (t, serverType, serverFamily) { var client1 = new Client({ infoHash: infoHash, - announce: [ announceUrl ], + announce: [announceUrl], peerId: peerId, port: 6881, wrtc: wrtc @@ -93,7 +93,7 @@ function serverTest (t, serverType, serverFamily) { var client2 = new Client({ infoHash: infoHash, - announce: [ announceUrl ], + announce: [announceUrl], peerId: peerId2, port: 6882, wrtc: wrtc @@ -113,7 +113,7 @@ function serverTest (t, serverType, serverFamily) { var client3 = new Client({ infoHash: infoHash, - announce: [ announceUrl ], + announce: [announceUrl], peerId: peerId3, port: 6880, wrtc: wrtc