mirror of
https://github.com/webtorrent/bittorrent-tracker.git
synced 2025-02-21 20:59:02 +00:00
don't crash if torrent.announce is undefined
This commit is contained in:
parent
8ba742eed4
commit
48dcab8420
@ -49,11 +49,8 @@ function Client (peerId, port, torrent, opts) {
|
|||||||
|
|
||||||
debug('new client %s', self._infoHash.toString('hex'))
|
debug('new client %s', self._infoHash.toString('hex'))
|
||||||
|
|
||||||
if (typeof torrent.announce === 'string') {
|
if (typeof torrent.announce === 'string') torrent.announce = [ torrent.announce ]
|
||||||
// magnet-uri returns a string if the magnet uri only contains one 'tr' parameter
|
self._trackers = (torrent.announce || [])
|
||||||
torrent.announce = [ torrent.announce ]
|
|
||||||
}
|
|
||||||
self._trackers = torrent.announce
|
|
||||||
.filter(function (announceUrl) {
|
.filter(function (announceUrl) {
|
||||||
return announceUrl.indexOf('udp://') === 0 || announceUrl.indexOf('http://') === 0
|
return announceUrl.indexOf('udp://') === 0 || announceUrl.indexOf('http://') === 0
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user