mirror of
https://github.com/webtorrent/bittorrent-tracker.git
synced 2025-01-31 02:21:36 +00:00
'url.parse' was deprecated since v11.0.0. Use 'url.URL' constructor instead
This commit is contained in:
parent
2c3058294b
commit
c37aac7277
11
client.js
11
client.js
@ -5,7 +5,7 @@ const once = require('once')
|
||||
const parallel = require('run-parallel')
|
||||
const Peer = require('simple-peer')
|
||||
const uniq = require('uniq')
|
||||
const url = require('url')
|
||||
const URL = require('url').URL
|
||||
|
||||
const common = require('./lib/common')
|
||||
const HTTPTracker = require('./lib/client/http-tracker') // empty object in browser
|
||||
@ -85,7 +85,14 @@ class Client extends EventEmitter {
|
||||
|
||||
this._trackers = announce
|
||||
.map(announceUrl => {
|
||||
const parsedUrl = url.parse(announceUrl)
|
||||
let parsedUrl
|
||||
try {
|
||||
parsedUrl = new URL(announceUrl)
|
||||
} catch (err) {
|
||||
nextTickWarn(new Error(`Invalid tracker URL: ${announceUrl}`))
|
||||
return null
|
||||
}
|
||||
|
||||
const port = parsedUrl.port
|
||||
if (port < 0 || port > 65535) {
|
||||
nextTickWarn(new Error(`Invalid tracker port: ${announceUrl}`))
|
||||
|
Loading…
Reference in New Issue
Block a user