2022-12-05 22:06:54 +00:00
|
|
|
import common from '../lib/common.js'
|
|
|
|
import test from 'tape'
|
2014-12-18 05:18:46 +00:00
|
|
|
|
2017-04-14 19:50:19 +00:00
|
|
|
// https://github.com/webtorrent/webtorrent/issues/196
|
2021-06-15 01:54:41 +00:00
|
|
|
test('encode special chars +* in http tracker urls', t => {
|
2020-10-29 04:57:47 +00:00
|
|
|
const q = Object.create(null)
|
2020-05-10 18:30:06 +00:00
|
|
|
q.info_hash = Buffer.from('a2a15537542b22925ad10486bf7a8b2a9c42f0d1', 'hex').toString('binary')
|
|
|
|
|
2020-10-29 04:57:47 +00:00
|
|
|
const encoded = 'info_hash=%A2%A1U7T%2B%22%92Z%D1%04%86%BFz%8B%2A%9CB%F0%D1'
|
2014-12-18 05:18:46 +00:00
|
|
|
t.equal(common.querystringStringify(q), encoded)
|
|
|
|
|
|
|
|
// sanity check that encode-decode matches up
|
|
|
|
t.deepEqual(common.querystringParse(common.querystringStringify(q)), q)
|
|
|
|
|
|
|
|
t.end()
|
|
|
|
})
|