diff --git a/lib/server/parse-http.js b/lib/server/parse-http.js index a6ba6a568..634c528a2 100644 --- a/lib/server/parse-http.js +++ b/lib/server/parse-http.js @@ -5,10 +5,12 @@ import common from '../common.js' export default function (req, opts) { if (!opts) opts = {} const s = req.url.split('?') + const p = s[0].split('/') + p.shift(); const params = common.querystringParse(s[1]) params.type = 'http' - if (opts.action === 'announce' || s[0] === '/announce') { + if (opts.action === 'announce' || p[0] === 'announce') { params.action = common.ACTIONS.ANNOUNCE if (typeof params.info_hash !== 'string' || params.info_hash.length !== 20) { @@ -47,7 +49,7 @@ export default function (req, opts) { params.addr = `${common.IPV6_RE.test(params.ip) ? `[${params.ip}]` : params.ip}:${params.port}` params.headers = req.headers - } else if (opts.action === 'scrape' || s[0] === '/scrape') { + } else if (opts.action === 'scrape' || p[0] === 'scrape') { params.action = common.ACTIONS.SCRAPE if (typeof params.info_hash === 'string') params.info_hash = [params.info_hash]