BackendStack21 / 0http

Zero friction HTTP requests router. The need for speed!
https://0http.21no.de
MIT License
158 stars 11 forks source link

Feature request: Replace legacy dependency for querystring parsing with URLSearchParams #25

Closed spurreiter closed 2 years ago

spurreiter commented 2 years ago

IMHO there is no need to relay on the legacy querystring.parse method any longer, which is used in https://github.com/BackendStack21/0http/blob/master/lib/utils/queryparams.js .

Is there a chance to replace it with the native URLSearchParams? Maybe this gives an additional performance boost?

E.g.

module.exports = (req, url) => {
  const [path, search] = url.split('?')
  const searchParams = new URLSearchParams(search.replace(/\[\]=/g, '='))
  req.path = path
  req.query = Object.fromEntries(searchParams)
}
jkyberneees commented 2 years ago

Hi @spurreiter , thanks for contributing to this project.

You are totally right, it's time to upgrade the query string parsing support. Would you like to push the PR so this contribution is tracked? Otherwise, I am happy to take over. Let me know.

Thanks in advance

spurreiter commented 2 years ago

Hi @jkyberneees, Thanks. Yes will create a PR.

jkyberneees commented 2 years ago

Feature was released in https://github.com/BackendStack21/0http/releases/tag/v3.4.0