Error with casters and )
Hi and sorry for my poor english. I've a problem with ')' char when i try to force cast with string() or use casters with a custom function. To reproduce the issue:
const val = aqp("key1=string(abc))");
console.log(val);
const val2 = aqp("key1=stringPers(abc))", {
casters: {
stringPers: (val: string) => val,
},
});
console.log(val2);
with '(' char works very well.
A workaround seems to use castParams that works with ')' but fails with ',' (the key is converted in array with $in operator)
To reproduce:
const val3 = aqp("key1=a,b,c,)&key2=abc)", {
castParams: {
key1: "string",
key2: "string",
},
});
console.log(val3);
So i haven't still find a way to cast a key with ')' and ',' to simple string
Thanks for help and compliments for your package, is very useful.
Filippo
Hi! So to understand, you have a query param value, which contains both , and ) reserved characters, like abc,), that you'd like to be extracted as a single string?
We could probably do a PR to make the value separator character (right now ,) an option. This way you could change it to a character you are not using as part of your string (like |)? Would that work?
Hi Loris and thanks for reply. Yes, i've a query param value that can contains both ',', ')'
We could probably do a PR to make the value separator character (right now ,) an option.
It's sound like a perfect solution for my problem