@@ -12,11 +12,13 @@ function parseHttpRequest (req, options) {
1212 if ( options . action === 'announce' || s [ 0 ] === '/announce' ) {
1313 params . action = common . ACTIONS . ANNOUNCE
1414
15- if ( typeof params . info_hash !== 'string' || params . info_hash . length !== 20 )
15+ if ( typeof params . info_hash !== 'string' || params . info_hash . length !== 20 ) {
1616 throw new Error ( 'invalid info_hash' )
17+ }
1718 params . info_hash = common . binaryToHex ( params . info_hash )
18- if ( typeof params . peer_id !== 'string' || params . peer_id . length !== 20 )
19+ if ( typeof params . peer_id !== 'string' || params . peer_id . length !== 20 ) {
1920 throw new Error ( 'invalid peer_id' )
21+ }
2022 params . peer_id = common . binaryToHex ( params . peer_id )
2123
2224 params . port = Number ( params . port )
@@ -35,13 +37,13 @@ function parseHttpRequest (req, options) {
3537 params . addr = ( common . IPV6_RE . test ( params . ip ) ? '[' + params . ip + ']' : params . ip ) + ':' + params . port
3638 } else if ( options . action === 'scrape' || s [ 0 ] === '/scrape' ) {
3739 params . action = common . ACTIONS . SCRAPE
38- if ( typeof params . info_hash === 'string' )
39- params . info_hash = [ params . info_hash ]
40+ if ( typeof params . info_hash === 'string' ) params . info_hash = [ params . info_hash ]
4041
4142 if ( Array . isArray ( params . info_hash ) ) {
4243 params . info_hash = params . info_hash . map ( function ( binaryInfoHash ) {
43- if ( typeof binaryInfoHash !== 'string' || binaryInfoHash . length !== 20 )
44+ if ( typeof binaryInfoHash !== 'string' || binaryInfoHash . length !== 20 ) {
4445 throw new Error ( 'invalid info_hash' )
46+ }
4547 return common . binaryToHex ( binaryInfoHash )
4648 } )
4749 }
0 commit comments