mirror of
https://github.com/webtorrent/bittorrent-tracker.git
synced 2024-12-14 19:36:24 +00:00
Merge pull request #168 from feross/fix-167
Fix Client.scrape returns no error on invalid URL
This commit is contained in:
commit
17807dc608
@ -138,6 +138,7 @@ Client.scrape = function (opts, cb) {
|
||||
|
||||
var client = new Client(clientOpts)
|
||||
client.once('error', cb)
|
||||
client.once('warning', cb)
|
||||
|
||||
var len = Array.isArray(opts.infoHash) ? opts.infoHash.length : 1
|
||||
var results = {}
|
||||
|
@ -85,6 +85,34 @@ test('ws: scrape using Client.scrape static method', function (t) {
|
||||
clientScrapeStatic(t, 'ws')
|
||||
})
|
||||
|
||||
// Ensure the callback function gets called when an invalid url is passed
|
||||
function clientScrapeStaticInvalid (t, serverType) {
|
||||
var announceUrl = serverType + '://invalid.lol'
|
||||
if (serverType === 'http') announceUrl += '/announce'
|
||||
|
||||
var client = Client.scrape({
|
||||
announce: announceUrl,
|
||||
infoHash: fixtures.leaves.parsedTorrent.infoHash,
|
||||
wrtc: {}
|
||||
}, function (err, data) {
|
||||
t.ok(err instanceof Error)
|
||||
t.end()
|
||||
})
|
||||
if (serverType === 'ws') common.mockWebsocketTracker(client)
|
||||
}
|
||||
|
||||
test.only('http: scrape using Client.scrape static method (invalid url)', function (t) {
|
||||
clientScrapeStaticInvalid(t, 'http')
|
||||
})
|
||||
|
||||
test('udp: scrape using Client.scrape static method (invalid url)', function (t) {
|
||||
clientScrapeStaticInvalid(t, 'udp')
|
||||
})
|
||||
|
||||
test('ws: scrape using Client.scrape static method (invalid url)', function (t) {
|
||||
clientScrapeStaticInvalid(t, 'ws')
|
||||
})
|
||||
|
||||
function clientScrapeMulti (t, serverType) {
|
||||
var infoHash1 = fixtures.leaves.parsedTorrent.infoHash
|
||||
var infoHash2 = fixtures.alice.parsedTorrent.infoHash
|
||||
|
Loading…
Reference in New Issue
Block a user