Skip to content

Commit 74a48f9

Browse files
committed
tweak parseHttpRequest
1 parent 7356e34 commit 74a48f9

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

lib/server/parse-http.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@ export default parseHttpRequest
55
function parseHttpRequest (req, opts) {
66
if (!opts) opts = {}
77
const s = req.url.split('?')
8+
const p = s[0].split('/')
9+
p.shift();
810
const params = common.querystringParse(s[1])
911
params.type = 'http'
1012

11-
if (opts.action === 'announce' || s[0] === '/announce') {
13+
if (opts.action === 'announce' || p[0] === 'announce') {
1214
params.action = common.ACTIONS.ANNOUNCE
1315

1416
if (typeof params.info_hash !== 'string' || params.info_hash.length !== 20) {
@@ -39,7 +41,7 @@ function parseHttpRequest (req, opts) {
3941
params.addr = `${common.IPV6_RE.test(params.ip) ? `[${params.ip}]` : params.ip}:${params.port}`
4042

4143
params.headers = req.headers
42-
} else if (opts.action === 'scrape' || s[0] === '/scrape') {
44+
} else if (opts.action === 'scrape' || p[0] === 'scrape') {
4345
params.action = common.ACTIONS.SCRAPE
4446

4547
if (typeof params.info_hash === 'string') params.info_hash = [params.info_hash]

0 commit comments

Comments
 (0)