Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

trouter

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

trouter - npm Package Compare versions

Comparing version 3.0.2 to 3.1.0

9

index.js

@@ -35,3 +35,3 @@ const parse = require('regexparam');

let isHEAD=(method === 'HEAD');
let i=0, j=0, tmp, arr=this.routes;
let i=0, j=0, k, tmp, arr=this.routes;
let matches=[], params={}, handlers=[];

@@ -41,5 +41,10 @@ for (; i < arr.length; i++) {

if (tmp.method.length === 0 || tmp.method === method || isHEAD && tmp.method === 'GET') {
if (tmp.keys.length > 0) {
if (tmp.keys === false) {
matches = tmp.pattern.exec(url);
if (matches === null) continue;
if (matches.groups !== void 0) for (k in matches.groups) params[k]=matches.groups[k];
tmp.handlers.length > 1 ? (handlers=handlers.concat(tmp.handlers)) : handlers.push(tmp.handlers[0]);
} else if (tmp.keys.length > 0) {
matches = tmp.pattern.exec(url);
if (matches === null) continue;
for (j=0; j < tmp.keys.length;) params[tmp.keys[j]]=matches[++j];

@@ -46,0 +51,0 @@ tmp.handlers.length > 1 ? (handlers=handlers.concat(tmp.handlers)) : handlers.push(tmp.handlers[0]);

{
"name": "trouter",
"version": "3.0.2",
"version": "3.1.0",
"repository": "lukeed/trouter",

@@ -32,3 +32,3 @@ "description": "🐟 A fast, small-but-mighty, familiar ~fish~ router",

"dependencies": {
"regexparam": "^1.2.0"
"regexparam": "^1.3.0"
},

@@ -38,5 +38,5 @@ "devDependencies": {

"esm": "3.2.22",
"tap-spec": "^5.0.0",
"tape": "4.10.1"
"tap-spec": "5.0.0",
"tape": "4.11.0"
}
}

@@ -68,8 +68,10 @@ # trouter [![Build Status](https://badgen.now.sh/travis/lukeed/trouter)](https://travis-ci.org/lukeed/trouter)

#### pattern
Type: `String`
Type: `String` or `RegExp`
Unlike most router libraries, Trouter does not use `RegExp` to determine pathname matches. Instead, it uses string comparison which is much faster, but also limits the pattern complexity.
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 pattern types are:
> **Important:** RegExp named capture groups are [supported in Node.js 10.x](https://node.green/#ES2018-features--RegExp-named-capture-groups) and above!
The supported route pattern types are:
* static (`/users`)

@@ -76,0 +78,0 @@ * named parameters (`/users/:id`)

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc