data icon indicating copy to clipboard operation
data copied to clipboard

Consider use of qs library to serialize data into the url

Open snewcomer opened this issue 4 years ago • 4 comments

Right now we are serializing the data into the url with an implementation mirroring ajax. See serializeQueryParams.

https://github.com/ljharb/qs

e.g.

qs.stringify({ a: { b: { c: 'd', e: 'f' } } });
// 'a[b][c]=d&a[b][e]=f'

ref #7824 See - https://github.com/ljharb/qs#rfc-3986-and-rfc-1738-space-encoding

snewcomer avatar Jan 02 '22 04:01 snewcomer

This library would also resolve https://github.com/emberjs/data/pull/7721

assert.equal(qs.stringify({ a: '' }), 'a=');

snewcomer avatar Jan 02 '22 04:01 snewcomer

This is likely more bytes than what we could write ourselves. However, this would make us "more robust" and less prone to issues for our users.

snewcomer avatar Jan 02 '22 04:01 snewcomer

I was looking into this package myself yesterday, was a bit concerned though looking at the bundle size for it (https://bundlephobia.com/package/[email protected])

acorncom avatar Jun 29 '22 07:06 acorncom

https://github.com/sindresorhus/query-string might also be of interest

acorncom avatar Jun 29 '22 07:06 acorncom

For the RequestManager RFC https://github.com/emberjs/rfcs/pull/860 url building is brought out of adapter in a way that this is mostly a consuming app concern. I don't think we need to change what the adapters do today; however, we may want to consider a new default for the url-builder utility.

qs being a cjs module (and a rather large one at that) is a non-starter and query-string hides its size with dependencies. There's probably one that is built for browsers only that is fairly tiny, we should research.

runspired avatar Nov 17 '22 02:11 runspired

we've implemented a simple query string builder that's optional for the request builders work. If someone wants to use qs (highly discouraged fwiw) all they need to do is install qs and use it to build their query params for the url they pass to request

runspired avatar Aug 21 '23 05:08 runspired