tslog icon indicating copy to clipboard operation
tslog copied to clipboard

Feature Request: Case insensitive alternative to maskAnyRegEx?

Open olivierlacan opened this issue 3 years ago • 1 comments

Right now maskAnyRegEx is case sensitive by default. Since all strings supplied in the array are joined with a pipe (|) it's not possible to supply a /i global flag (a /g global flag is hardcoded).

So if you set the following: maskAnyRegEx: ["pass.*"], it will not catch this string dbPassword.

That's fairly understandable and you can always use maskValuesOfKeys but I feel like the feature would be a lot safer if either:

  • all maskAnyRegEx values defaulted to use both g and i flags so matches are both global and case insensitive.
  • a different option is added (something like maskAnyRegExCaseInsensitive) that explicitly supports case insensitivity by default so that maskAnyRegExCaseInsensitive: ["pass.*"] will now catch PASSWORD, dbPassword, or pAsSwOrD.

Here's the regex tester showing these values with the case insensitive turned on: https://regex101.com/r/GQJbo9/1

Thanks for considering it, I'm really enjoying tslog.

olivierlacan avatar May 18 '22 16:05 olivierlacan

Thank you! I will put it on the agenda for V4 and consider it. Have to put in some thoughts, though.

terehov avatar Aug 23 '22 19:08 terehov

I've been working on a new, completely rewritten version (4.0). This version is way more flexible, and you can basically overwrite all the internal functionality, including this RegEx. Can you give it a go and let me know if that solves your problem?

  • npm i tslog@next

  • and run it with node --enable-source-maps or for TypeScript node --enable-source-maps --experimental-specifier-resolution=node --no-warnings --loader ts-node/esm

Here is an example on how to use it: https://github.com/fullstack-build/tslog/blob/v4/tests/Nodejs/6_json_Settings.test.ts#L124

terehov avatar Sep 29 '22 10:09 terehov

V4 is released now, so I'm going to close this issue. Feel free to open a new one if V4 didn't solve it for you.

Here are the docs: tslog.js.org

terehov avatar Nov 15 '22 18:11 terehov