From 48dcab8420b9b81e727fd1defc5eed55713d7dd0 Mon Sep 17 00:00:00 2001 From: Feross Aboukhadijeh Date: Sun, 17 Aug 2014 20:56:11 -0700 Subject: [PATCH] don't crash if torrent.announce is undefined --- client.js | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/client.js b/client.js index 68b02b2..d0b40c8 100644 --- a/client.js +++ b/client.js @@ -49,11 +49,8 @@ function Client (peerId, port, torrent, opts) { debug('new client %s', self._infoHash.toString('hex')) - if (typeof torrent.announce === 'string') { - // magnet-uri returns a string if the magnet uri only contains one 'tr' parameter - torrent.announce = [ torrent.announce ] - } - self._trackers = torrent.announce + if (typeof torrent.announce === 'string') torrent.announce = [ torrent.announce ] + self._trackers = (torrent.announce || []) .filter(function (announceUrl) { return announceUrl.indexOf('udp://') === 0 || announceUrl.indexOf('http://') === 0 })