Skip to content

Commit ae8421b

Browse files
committed
fix: 🐛remove incorrect search params
1 parent c955b63 commit ae8421b

File tree

1 file changed

+22
-2
lines changed

1 file changed

+22
-2
lines changed

lib/client/http-tracker.js

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,28 @@ class HTTPTracker extends Tracker {
121121
}
122122

123123
async _request (requestUrl, params, cb) {
124-
const _parsedUrl = new URL(requestUrl + (requestUrl.indexOf('?') === -1 ? '?' : '&') + common.querystringStringify(params))
125-
const parsedUrl = new URL(_parsedUrl.toString())
124+
const parsedUrl = new URL(
125+
requestUrl +
126+
(requestUrl.indexOf('?') === -1 ? '?' : '&') +
127+
common.querystringStringify(
128+
Object.fromEntries(
129+
Object
130+
.entries(params)
131+
.filter(([_, value]) =>
132+
!(
133+
value === undefined
134+
|| value === null
135+
|| value === ''
136+
|| (
137+
typeof value === 'number'
138+
&& isNaN(value)
139+
)
140+
)
141+
)
142+
)
143+
)
144+
)
145+
126146
parsedUrl.searchParams.set(
127147
'info_hash',
128148
new URLSearchParams({ info_hash: escape(params.info_hash) })

0 commit comments

Comments
 (0)