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.2.0 to 3.2.1

22

index.js
const parse = require('regexparam');
const MAP = {
"": 0,
GET: 1,
HEAD: 2,
PATCH: 3,
OPTIONS: 4,
CONNECT: 5,
DELETE: 6,
TRACE: 7,
POST: 8,
PUT: 9,
};
module.exports = class Trouter {

@@ -22,3 +35,3 @@ constructor() {

let { keys, pattern } = parse(route, true);
this.routes.push({ keys, pattern, method:'', handlers });
this.routes.push({ keys, pattern, method: '', handlers, midx: MAP[''] });
return this;

@@ -30,3 +43,3 @@ }

let handlers = [].concat.apply([], fns);
this.routes.push({ keys, pattern, method, handlers });
this.routes.push({ keys, pattern, method, handlers, midx: MAP[method] });
return this;

@@ -36,3 +49,4 @@ }

find(method, url) {
let isHEAD=(method === 'HEAD');
let midx = MAP[method];
let isHEAD = (midx === 2);
let i=0, j=0, k, tmp, arr=this.routes;

@@ -42,3 +56,3 @@ let matches=[], params={}, handlers=[];

tmp = arr[i];
if (tmp.method.length === 0 || tmp.method === method || isHEAD && tmp.method === 'GET') {
if (tmp.midx === midx || tmp.midx === 0 || (isHEAD && tmp.midx===1) ) {
if (tmp.keys === false) {

@@ -45,0 +59,0 @@ matches = tmp.pattern.exec(url);

2

package.json
{
"name": "trouter",
"version": "3.2.0",
"version": "3.2.1",
"repository": "lukeed/trouter",

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

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