Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/webtorrent/webtorrent.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFeross Aboukhadijeh <feross@feross.org>2015-06-11 06:59:03 +0300
committerFeross Aboukhadijeh <feross@feross.org>2015-06-11 06:59:03 +0300
commite677499e46d3b905f54464ded98c832faaeaad37 (patch)
tree364da0c366c0d10928859c3fc55adccaab600f5b /index.js
parentad75823610867b54ad5a4831229899c329c0b793 (diff)
webtorrent.get should not throw
Diffstat (limited to 'index.js')
-rw-r--r--index.js7
1 files changed, 6 insertions, 1 deletions
diff --git a/index.js b/index.js
index c59273f..145be69 100644
--- a/index.js
+++ b/index.js
@@ -125,7 +125,12 @@ Object.defineProperty(WebTorrent.prototype, 'ratio', {
WebTorrent.prototype.get = function (torrentId) {
var self = this
if (torrentId instanceof Torrent) return torrentId
- var parsed = parseTorrent(torrentId)
+ var parsed
+ try {
+ parsed = parseTorrent(torrentId)
+ } catch (err) {
+ return null
+ }
if (!parsed.infoHash) throw new Error('Invalid torrent identifier')
for (var i = 0, len = self.torrents.length; i < len; i++) {
var torrent = self.torrents[i]