Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix parsed torrent #1770

Closed
wants to merge 3 commits into from
Closed
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

Add test for non-bittorrent URNs

  • Loading branch information
alxhotel committed Oct 28, 2019
commit acca5b9e9d07dfd27227a3bf92a730ccae87178b
@@ -205,3 +205,35 @@ test('client.add: invalid torrent id: short buffer', function (t) {

client.add(Buffer.from('abc'))
})

test('client.add: non-bittorrent URNs', function (t) {
const magnets = [
'magnet:?xt=urn:sha1:PDAQRAOQQRYS76MRZJ33LK4MMVZBDSCL',
'magnet:?xt=urn:tree:tiger:IZZG2KNL4BKA7LYEKK5JAX6BQ27UV4QZKPL2JZQ',
'magnet:?xt=urn:bitprint:QBMYI5FTYSFFSP7HJ37XALYNNVYLJE27.E6ITPBX6LSBBW34T3UGPIVJDNNJZIQOMP5WNEUI',
'magnet:?xt=urn:ed2k:31D6CFE0D16AE931B73C59D7E0C089C0',
'magnet:?xt=urn:aich:D6EUDGK2DBTBEZ2XVN3G6H4CINSTZD7M',
'magnet:?xt=urn:kzhash:35759fdf77748ba01240b0d8901127bfaff929ed1849b9283f7694b37c192d038f535434',
'magnet:?xt=urn:md5:4e7bef74677be349ccffc6a178e38299'
]

t.plan(magnets.length * 2 + 1)

var done = 0
var client = new WebTorrent({ dht: false, tracker: false })

client.on('error', function (err) {
t.ok(err instanceof Error)
t.ok(err.message.indexOf('Invalid torrent identifier') >= 0)

done += 1

if (done === magnets.length) client.destroy(function (err) { t.error(err, 'client destroyed') })
})
client.on('warning', function (err) { t.fail(err) })

// Non-bittorrent URNs (examples from Wikipedia)
magnets.forEach(function (magnet) {
client.add(magnet)
})
})
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.