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

Error with casters and ) #138

Open
scare82 opened this issue May 25, 2022 · 2 comments
Open

Error with casters and ) #138

scare82 opened this issue May 25, 2022 · 2 comments

Comments

@scare82
Copy link

scare82 commented May 25, 2022

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

@loris
Copy link
Owner

loris commented Jun 2, 2022

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?

@scare82
Copy link
Author

scare82 commented Jun 6, 2022

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants