
Research
GemStuffer Campaign Abuses RubyGems as Exfiltration Channel Targeting UK Local Government
GemStuffer abuses RubyGems as an exfiltration channel, packaging scraped UK council portal data into junk gems published from new accounts.
trouter-paths
Advanced tools
A fast, small-but-mighty, familiar
fishrouter for paths only
This fork of the original project removes the support for HTTP verbs, which makes this module suitable for client-side routers, which run only in web browsers. Otherwise the API is the same.
If you use Node.js:
$ npm install --save trouter-paths
If you write a pure web page:
<script src="https://unpkg.com/trouter-paths@1.2.1/dist/index.umd.js"></script>
If you use Node.js:
const Trouter = require('trouter-paths');
const router = new Trouter();
// Define all routes
router
.add('/users', _ => {
console.log('> Showing all users');
})
.add('/users/:id', val => {
console.log('~> Showing user with ID:', val);
});
// Find a route definition
let obj = router.find('/users/123');
//=> obj.params ~> { id:123 }
//=> obj.handlers ~> Array<Function>
// Execute the handlers, passing value
obj.handlers.forEach(fn => {
fn(obj.params.id);
});
//=> ~> Showing user with ID: 123
// Returns empty keys when no match
router.find('/foo');
//=> { params:{}, handlers:[] }
If you write a pure web page:
<script src="https://unpkg.com/trouter-paths@1.2.1/dist/index.umd.js"></script>
<script>
const router = new trouterPaths.Trouter();
// The usage is the same as in the example for Node.js above.
</script>
Initializes a new Trouter instance.
Returns: self
Stores a pattern internally, along with its handler(s).
Type: String or RegExp
Trouter supports simple route patterns which are fast and well readable but limited. If you need more complex patterns, you can pass an instance of RegExp with parameters specified as named capture groups.
The supported route pattern types are:
/users)/users/:id)/users/:id/books/:title)/users/:id?/books/:title?)/movies/:title.mp4, movies/:title.(mp4|mov))/users/*)Type: Function
The function(s) that should be tied to this pattern.
Because this is a rest parameter, whatever you pass will always be cast to an Array.
Important: Trouter does not care what your function signature looks like!
You are not bound to the(req, res)standard, or even passing aFunctionat all!
Unlike trouter.use, the pattern you defined IS RESTRICTIVE. This means that the URL must match the defined pattern exactly – or have the appropriate optional and/or wildcard segments to accommodate the desired flexibility.
router.add('/foo', '/foo');
router.add('/foo/:name', '/foo/:name');
router.add('/foo/:name', '/foo/:name');
router.add('/foo/:name/hello', '/foo/:name/hello');
router.find('/foo').handlers;
//=> ['/foo']
router.find('/foo/bar').handlers;
//=> ['/foo/:name']
router.find('/foo/bar/hello').handlers;
//=> [/foo/:name/hello']
Compare this snippet with the one below to see differences between trouter.use and this method.
Returns: self
This is an alias for trouter.add(pattern, ...handlers). However, unlike trouter.sdd, the pattern you defined IS NOT RESTRICTIVE, which means that the route will match any & all URLs that start (but not end) with a matching segment.
router.use('/foo', '/foo');
router.use('/foo/:name', '/foo/:name');
router.add('/foo/:name/hello', 'HEAD /foo/:name/hello');
router.find('/foo').handlers;
//=> ['/foo']
router.find('/foo/bar').handlers;
//=> ['/foo', '/foo/:name']
router.find('/foo/bar/hello').handlers;
//=> ['/foo', '/foo/:name', '/foo/:name/hello']
Compare this snippet with the one above to see differences between trouter.add and this method.
Returns: Object
Searches within current instance for all patterns that satisfy the current url.
Important: Parameters and handlers are assembled/gathered in the order that they were defined!
This method will always return an Object with params and handlers keys.
params — Object whose keys are the named parameters of your route pattern.handlers — Array containing the ...handlers provided to .add() or .use()Note: The
handlersandparamskeys will be empty if no matches were found.
Type: String
The URL used to match against pattern definitions. This is typically req.url.
Run on Node v12.16.1
/ x 5,691,288 ops/sec ±0.95% (92 runs sampled)
/users x 5,444,762 ops/sec ±0.41% (97 runs sampled)
/users/:id x 1,813,200 ops/sec ±0.58% (95 runs sampled)
/users/:id/books/:title? x 2,434,211 ops/sec ±0.39% (96 runs sampled)
/users/:id/books/:title x 1,148,469 ops/sec ±0.36% (95 runs sampled)
/ x 5,068,009 ops/sec ±0.48% (89 runs sampled)
/users x 4,931,024 ops/sec ±0.36% (96 runs sampled)
/users/:id x 1,861,155 ops/sec ±0.45% (92 runs sampled)
/users/:id/books/:title? x 3,014,640 ops/sec ±0.40% (98 runs sampled)
/users/:id/books/:title x 1,288,142 ops/sec ±0.79% (96 runs sampled)
/ x 3,058,566 ops/sec ±0.53% (94 runs sampled)
/users x 2,052,082 ops/sec ±0.40% (96 runs sampled)
/users/:id x 1,002,815 ops/sec ±0.83% (95 runs sampled)
/users/:id/books/:title? x 632,026 ops/sec ±0.75% (93 runs sampled)
/users/:id/books/:title x 586,978 ops/sec ±0.38% (96 runs sampled)
MIT
Copyright 2020 © Ferdinand Prantl
Copyright 2018-2019 © Luke Edwards
FAQs
A fast, small-but-mighty, familiar ~fish~ router for paths only
We found that trouter-paths demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Research
GemStuffer abuses RubyGems as an exfiltration channel, packaging scraped UK council portal data into junk gems published from new accounts.

Company News
Socket was named to the Rising in Cyber 2026 list, recognizing 30 private cybersecurity startups selected by CISOs and security executives.

Research
Socket detected 84 compromised TanStack npm package artifacts modified with suspected CI credential-stealing malware.