From 74a48f9383417c983500f92af0307aec5e69289d Mon Sep 17 00:00:00 2001 From: Leask Wong Date: Wed, 8 Feb 2023 19:32:18 -0500 Subject: [PATCH] tweak parseHttpRequest --- lib/server/parse-http.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/server/parse-http.js b/lib/server/parse-http.js index 5847251f4..43c1fd27c 100644 --- a/lib/server/parse-http.js +++ b/lib/server/parse-http.js @@ -5,10 +5,12 @@ export default parseHttpRequest function parseHttpRequest (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) { @@ -39,7 +41,7 @@ function parseHttpRequest (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]