a simple way to filter strings
Want to see pretty graphs? Log in now!
npm install you-shall-not-pass
|1||downloads in the last week|
|4||downloads in the last month|
|Last Published By|
|Version||1.0.0 last updated a year ago|
|Keywords||filter, white, black, list, listed, whitelist, blacklist, string, check, security, field, enable, disable|
just a simple way to filter strings
It happens that you would like to filter something that if matches shall not pass.
Blacklist VS Whitelist
The function accepts optionally no list, blacklist, or whitelist, and it gives precedence to the white one.
However, if no list is provided and matches the input, the
youShallNotPass.maybe is returned instead.
To preserve the security intent, by maybe,
youShallNotPass(str) returns true but if you want to rely the blacklist 100% feel free to chnge the value.
// if you don't care about non checked things youShallNotPass.maybe = true;
youShallNotPass( str:string, [blacklist:Array|RegExp|null], [whitelist:Array|RegExp|null] ):boolean
These are few examples from the test file:
true === youShallNotPass( 'test', /\btest\b/ // blacklist ); true === youShallNotPass( 'test', [ // blacklist as list /\btes\b/, /\btest\b/ ] ); // as whitelisted, then stronger! false === youShallNotPass( 'test', /.*/, /\btest\b/ ); // same as above false === youShallNotPass( 'test', [ /.*/, /\btest\b/ ], [ /\btest\b/ ] );