ljharb / qs

A querystring parser with nesting support
BSD 3-Clause "New" or "Revised" License
8.53k stars 731 forks source link

stringify: can I use "encode: false" and "format: 'RFC1738'" options together #509

Open dante-blitz opened 3 months ago

dante-blitz commented 3 months ago

I am new to qs and am using it as part of react-instantsearch

I have the following code:


const queryString = qsModule.stringify(routeState, {
  encode: false,
  format: 'RFC1738',
})

which is giving me:

?music[0]=Hip%20Hop

Ideally I want the following

?music[0]=Hip+Hop

I've noticed that if I disable the "encoding: false" option I get:

?music%5B0%5D=Hip+Hop

Is there a way to combine both options to get the desired result...

?music[0]=Hip+Hop

Thanks in advance.

ljharb commented 3 months ago

try setting encodeValuesOnly to true