regexparam is a minimalist (399B) utility designed to convert URL-like route patterns (e.g., `/users/:id`) into JavaScript `RegExp` objects, extracting parameter keys in the process. It serves as a more lightweight and focused alternative to libraries like `path-to-regexp`. The current stable version is `3.0.0`. Releases occur periodically, addressing bug fixes and introducing minor breaking changes, typically every few months for major versions. Key differentiators include its extremely small footprint and its specific focus on basic routing patterns: static, parameter (with or without suffixes), optional parameters, wildcards, and optional wildcards. Unlike more comprehensive routing solutions, regexparam only handles parsing string patterns and does not manage a `keys` dictionary directly or mutate variables. It ships with CommonJS, ESModule, and UMD formats and includes TypeScript type definitions.
npm install regexparamVerified import paths — ran on the pinned version, not inferred.
Demonstrates how to parse a route pattern into a RegExp and keys, test paths against it, extract parameters, and inject parameters into a route string using `parse` and `inject`.
Review all routes utilizing optional wildcard patterns and verify their matching behavior against the new specification. Adjust application logic if the previous, incorrect behavior was relied upon.
Update import statements from `import regexparam from 'regexparam'` to `import { parse } from 'regexparam'` for ESM. For CommonJS, change `const regexparam = require('regexparam'); regexparam(...)` to `const { parse } = require('regexparam'); parse(...)`.Ensure your Node.js environment is version 8 or higher before upgrading to regexparam v2.0.0 or later.
Always prepend a leading slash to any path string passed to `pattern.test()` or `pattern.exec()` methods derived from `regexparam`.
Ensure all non-optional parameters defined in your route pattern are provided to the `inject` function to ensure complete path generation.
Change your CommonJS import and usage from `const regexparam = require('regexparam'); regexparam('/path')` to `const { parse } = require('regexparam'); parse('/path')`.Either update `regexparam` to v2.0.0 or later, or change your import to `import regexparam from 'regexparam'` and use `regexparam('/path')`.Upgrade to `regexparam` v3.0.0 and thoroughly test routes using optional wildcards (`*?`) to confirm expected matching behavior.
No dependency data recorded yet.