Skip to content

Commit 2983811

Browse files
committed
handle case where magnet uri has only one 'tr' param
1 parent 6f565ed commit 2983811

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

index.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,10 @@ function Client (peerId, port, torrent, opts) {
399399
self._numWant = self._opts.numWant || 80
400400
self._intervalMs = self._opts.interval || (30 * 60 * 1000) // default: 30 minutes
401401

402+
if (typeof torrent.announce === 'string') {
403+
// magnet-uri returns a string if the magnet uri only contains one 'tr' parameter
404+
torrent.announce = [torrent.announce]
405+
}
402406
self._trackers = torrent.announce.map(function (announceUrl) {
403407
return new Tracker(self, announceUrl, self._opts)
404408
})

test/client-large-torrent.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ var port = 6881
1111
// remove all tracker servers except a single UDP one, for now
1212
parsedTorrent.announce = [ 'udp://tracker.publicbt.com:80/announce' ]
1313

14-
test('client.start()', function (t) {
14+
test('large torrent: client.start()', function (t) {
1515
t.plan(4)
1616

1717
var client = new Client(peerId, port, parsedTorrent)

0 commit comments

Comments
 (0)