Polka: Double decoded req.query

Created on 30 Mar 2019  路  2Comments  路  Source: lukeed/polka

In "next" branch, reg.query got decoded twice!!!
using this as server:

const polka = require('polka')
polka()
.get('/', (req, res) => {
  res.end(JSON.stringify(req.query))
}).listen(8181, err => {
  if (err) throw err
  console.log(`Polka listening on port 8181`)
})

and "curling" it:

curl -v "http://127.0.0.1:8181/?i=TU10Z&n=smsitfix2&Q=%2b393383123549"

we got:

{"i":"TU10Z","n":"smsitfix2","Q":" 393383123549"}

instead of:

{"i":"TU10Z","n":"smsitfix2","Q":"+393383123549"}

may be @polka/url must not decode eagerly the url ...

bug

Most helpful comment

Took the opportunity to basically rewrite @polka/url & made it much faster in the process, haha

Closing this since it's pertinent to next specifically, and there's now a new version up.

Thanks!

All 2 comments

Ah, you're right. Thanks!

The @olka/url decodes it initially, and then passing req.query (string) thru querystring.parse will re-decode it again.

I'll push out a fix for this tonight :)

Took the opportunity to basically rewrite @polka/url & made it much faster in the process, haha

Closing this since it's pertinent to next specifically, and there's now a new version up.

Thanks!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

lukeed picture lukeed  路  10Comments

motss picture motss  路  3Comments

deadcoder0904 picture deadcoder0904  路  8Comments

ansarizafar picture ansarizafar  路  3Comments

paz-raon picture paz-raon  路  10Comments