File tree Expand file tree Collapse file tree 1 file changed +9
-2
lines changed
Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ const once = require('once')
55const parallel = require ( 'run-parallel' )
66const Peer = require ( 'simple-peer' )
77const uniq = require ( 'uniq' )
8- const url = require ( 'url' )
8+ const URL = require ( 'url' ) . URL
99
1010const common = require ( './lib/common' )
1111const HTTPTracker = require ( './lib/client/http-tracker' ) // empty object in browser
@@ -85,7 +85,14 @@ class Client extends EventEmitter {
8585
8686 this . _trackers = announce
8787 . map ( announceUrl => {
88- const parsedUrl = url . parse ( announceUrl )
88+ let parsedUrl
89+ try {
90+ parsedUrl = new URL ( announceUrl )
91+ } catch ( err ) {
92+ nextTickWarn ( new Error ( `Invalid tracker URL: ${ announceUrl } ` ) )
93+ return null
94+ }
95+
8996 const port = parsedUrl . port
9097 if ( port < 0 || port > 65535 ) {
9198 nextTickWarn ( new Error ( `Invalid tracker port: ${ announceUrl } ` ) )
You can’t perform that action at this time.
0 commit comments