route-recognizer is a compact JavaScript library (under 2KB) designed solely for matching paths against a set of registered routes. It functions as a low-level primitive for more comprehensive routing systems, such as `router.js`, which was notably used by Ember.js. Currently at version 0.3.4, last published in 2018, the library offers stable functionality for static, dynamic (e.g., `:id`), and wildcard (e.g., `*path`) segments. Its core differentiator is its minimalistic approach, focusing exclusively on route recognition and parameter extraction without handling routing logic, history, or view rendering. The package ships with TypeScript types, but its development status appears to be unmaintained given the last commit and release dates.
npm install route-recognizerVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to instantiate RouteRecognizer, add various route patterns including dynamic and star segments, and then use the `recognize` method to match paths and retrieve associated handlers and parameters.
Always test routes with ambiguous paths to ensure they resolve as intended. Structure route definitions from most specific to least specific, if possible, to align with the recognizer's internal sorting logic.
Consider alternatives for new projects. For existing projects, be aware that security updates or bug fixes are unlikely. Test thoroughly in modern environments.
Use dynamic segments (`:param`) for single path segments and star segments (`*param`) for multi-segment or trailing path matches.
For ES Modules: `import RouteRecognizer from 'route-recognizer';` For CommonJS: `const RouteRecognizer = require('route-recognizer');`Ensure `RouteRecognizer` is instantiated correctly: `const router = new RouteRecognizer();`
This specific error is unlikely to come directly from `route-recognizer` as it primarily deals with `recognize`. If encountered in a surrounding router, ensure the route name used for generation matches a registered route. For `route-recognizer` directly, verify that you are not trying to generate routes by name, but rather using `recognize` with a path string.
No dependency data recorded yet.