Skip to content

Commit 48dcab8

Browse files
committed
don't crash if torrent.announce is undefined
1 parent 8ba742e commit 48dcab8

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

client.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,8 @@ function Client (peerId, port, torrent, opts) {
4949

5050
debug('new client %s', self._infoHash.toString('hex'))
5151

52-
if (typeof torrent.announce === 'string') {
53-
// magnet-uri returns a string if the magnet uri only contains one 'tr' parameter
54-
torrent.announce = [ torrent.announce ]
55-
}
56-
self._trackers = torrent.announce
52+
if (typeof torrent.announce === 'string') torrent.announce = [ torrent.announce ]
53+
self._trackers = (torrent.announce || [])
5754
.filter(function (announceUrl) {
5855
return announceUrl.indexOf('udp://') === 0 || announceUrl.indexOf('http://') === 0
5956
})

0 commit comments

Comments
 (0)