don't modify passed in torrent object

This commit is contained in:
Feross Aboukhadijeh 2015-05-16 22:54:45 -07:00
parent e5560d8f00
commit 153402ae85

View File

@ -52,13 +52,16 @@ function Client (peerId, port, torrent, opts) {
debug('new client %s', self._infoHash.toString('hex'))
if (typeof torrent.announce === 'string') torrent.announce = [ torrent.announce ]
if (torrent.announce == null) torrent.announce = []
var trackerOpts = { interval: self._intervalMs }
var webrtcSupport = !!self._wrtc || typeof window !== 'undefined'
self._trackers = torrent.announce
var announce = (typeof torrent.announce === 'string')
? [ torrent.announce ]
: torrent.announce == null
? []
: torrent.announce
self._trackers = announce
.map(function (announceUrl) {
var protocol = url.parse(announceUrl).protocol