{"library":"safe-regex-test","title":"Safe Regex Tester","description":"safe-regex-test is a JavaScript utility designed to provide a robust and predictable method for testing regular expressions against strings. It addresses a specific security concern by safeguarding the regex testing mechanism from potential alterations or pollution of the global `RegExp.prototype` object, which can lead to unexpected behavior or vulnerabilities in less controlled environments. The current stable version is 1.1.0, last published over a year ago, indicating a mature project with a slow and deliberate release cadence, primarily focused on stability and specific bug fixes rather than frequent feature additions. Its key differentiator is this resilience against prototype tampering, offering a more secure alternative to direct `RegExp.prototype.test` usage, particularly in shared or potentially untrusted execution contexts.","language":"javascript","status":"active","last_verified":"Sun Apr 19","install":{"commands":["npm install safe-regex-test"],"cli":null},"imports":["import safeRegexTest from 'safe-regex-test';","const safeRegexTest = require('safe-regex-test');","import type { SafeRegexTester } from 'safe-regex-test';"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import safeRegexTest from 'safe-regex-test';\nimport assert from 'assert';\n\n// Create a robust regex tester function\nconst tester = safeRegexTest(/hello/i);\n\n// Test strings\nassert.ok(tester('Hello, world!'));\nassert.notOk(tester('Goodbye, world!'));\n\n// Demonstrate robustness against prototype pollution (conceptual, not runnable here without polluting global)\n// This library ensures that even if RegExp.prototype.test were modified, 'tester' would still behave correctly.\n// For example, if someone did: Object.defineProperty(RegExp.prototype, 'test', { value: () => true });\n// The 'tester' function created by safe-regex-test would still use the original, unpolluted 'test' logic.\n\nconst alwaysTrueTester = safeRegexTest(/any/);\nconsole.log('Testing with original regex:', alwaysTrueTester('any string'));\n","lang":"typescript","description":"Demonstrates how to import and use `safe-regex-test` to create a robust regex testing function, highlighting its core capability.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}