/ test / querystring.js
querystring.js
 1  import common from '../lib/common.js'
 2  import test from 'tape'
 3  
 4  // https://github.com/webtorrent/webtorrent/issues/196
 5  test('encode special chars +* in http tracker urls', t => {
 6    const q = Object.create(null)
 7    q.info_hash = Buffer.from('a2a15537542b22925ad10486bf7a8b2a9c42f0d1', 'hex').toString('binary')
 8  
 9    const encoded = 'info_hash=%A2%A1U7T%2B%22%92Z%D1%04%86%BFz%8B%2A%9CB%F0%D1'
10    t.equal(common.querystringStringify(q), encoded)
11  
12    // sanity check that encode-decode matches up
13    t.deepEqual(common.querystringParse(common.querystringStringify(q)), q)
14  
15    t.end()
16  })