handle case where magnet uri has only one 'tr' param

This commit is contained in:
Feross Aboukhadijeh 2014-05-14 12:46:15 -07:00
parent 6f565ed6fa
commit 2983811a71
2 changed files with 5 additions and 1 deletions

View File

@ -399,6 +399,10 @@ function Client (peerId, port, torrent, opts) {
self._numWant = self._opts.numWant || 80
self._intervalMs = self._opts.interval || (30 * 60 * 1000) // default: 30 minutes
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.map(function (announceUrl) {
return new Tracker(self, announceUrl, self._opts)
})

View File

@ -11,7 +11,7 @@ var port = 6881
// remove all tracker servers except a single UDP one, for now
parsedTorrent.announce = [ 'udp://tracker.publicbt.com:80/announce' ]
test('client.start()', function (t) {
test('large torrent: client.start()', function (t) {
t.plan(4)
var client = new Client(peerId, port, parsedTorrent)