Skip to content

Commit 153402a

Browse files
committed
don't modify passed in torrent object
1 parent e5560d8 commit 153402a

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

client.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,16 @@ function Client (peerId, port, torrent, opts) {
5252

5353
debug('new client %s', self._infoHash.toString('hex'))
5454

55-
if (typeof torrent.announce === 'string') torrent.announce = [ torrent.announce ]
56-
if (torrent.announce == null) torrent.announce = []
57-
5855
var trackerOpts = { interval: self._intervalMs }
5956
var webrtcSupport = !!self._wrtc || typeof window !== 'undefined'
6057

61-
self._trackers = torrent.announce
58+
var announce = (typeof torrent.announce === 'string')
59+
? [ torrent.announce ]
60+
: torrent.announce == null
61+
? []
62+
: torrent.announce
63+
64+
self._trackers = announce
6265
.map(function (announceUrl) {
6366
var protocol = url.parse(announceUrl).protocol
6467

0 commit comments

Comments
 (0)