Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Because Elysia uses fast-querystring to decode, treaty should use it to encode #79

Closed
wants to merge 1 commit into from

Conversation

MatthewAry
Copy link
Contributor

fast-querystring introduces several benefits when used to encode query strings:

Unsafe URL characters are automatically encoded such that they are not misinterpreted by the server
Suppose an endpoint has t.String({ format: 'email' }) on the query validator. If you tried to set the query string to test+1@test.com validation would fail because for some reason, the server would see the value as test+ @test.com or something. See: https://stackoverflow.com/questions/2322764/what-characters-must-be-escaped-in-an-http-query-string
By using this package we solve this problem with minimal impact to perf.

Able to encode arrays
Looking at the example posted on the readme in the fast-querystring repo:

const qs = require('fast-querystring')

// Parsing a querystring
console.log(qs.parse('hello=world&foo=bar&values=v1&values=v2'))
// {
//   hello: 'world',
//   foo: 'bar',
//   values: ['v1', 'v2']
// }

// Stringifying an object
console.log(qs.stringify({ foo: ['bar', 'baz'] }))
// 'foo=bar&foo=baz'

We see that fast-querystring will also handle arrays. This is helpful when you have situations where you might want to apply multiple filters to a data-table component and much more.

@SaltyAom
Copy link
Member

Thank you for your contribution, but I chose to got with #84 which doesn't add an extra dependency to save some space.

Feels free to open an issue if further discussion need.

@SaltyAom SaltyAom closed this Apr 23, 2024
@MatthewAry MatthewAry deleted the query-transformer branch April 23, 2024 14:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants