Closed zwwtj2014 closed 3 years ago
The format defines that for the default encoder - can you elaborate on your use case, and why passing your own encoder doesn’t solve it?
can you elaborate on your use case, and why passing your own encoder doesn’t solve it?
passing my own encoder can solve it, but it cannot reuse existing features of the default encoder.
my use case:
qs.stringify({ aaa: '=+/' })
// now: aaa=%3D%2B%2F
// but i want: aaa=%3D+%2F
So in my use case, i want all the other features of the default encoder expect for a few special characters , such as the +
above. If i self-implement the encoder, i have two ideas:
%2B
to +
And i do not think the two ideas above are better than giving a hook 😄
but it cannot reuse existing features of the default encoder.
Sure you can. Your custom encoder gets the default encoder as its second argument.
The first example seems like the best approach at the moment. I agree that adding a hook is more convenient for your use case, but I'm still not clear on what it is - why would you want the + unencoded on the default format? is this alternate format something standard - or something that somebody besides you would need?
I'm still not clear on what it is - why would you want the + unencoded on the default format? is this alternate format something standard - or something that somebody besides you would need?
yep,maybe server side unencode use non-standard lib, and i have asked them to check
The first example seems like the best approach at the moment.
ok, thanks.. and i will use first example to polyfill until they check done.
https://github.com/ljharb/qs/blob/master/lib/utils.js#L157
hi, default encoder can support filter specified characters?
maybe implement as above?
fliterCharacter
is a function used to determine characterc
whether escape is required, and passed by the user