Socket
Socket
Sign inDemoInstall

@middy/http-router

Package Overview
Dependencies
Maintainers
3
Versions
106
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@middy/http-router - npm Package Compare versions

Comparing version 4.6.1 to 4.6.2

17

index.js

@@ -8,8 +8,11 @@ import { createError } from '@middy/util';

let { method, path, handler } = route;
// Prevents `routesType[method][path] = handler` from flagging: This assignment may alter Object.prototype if a malicious '__proto__' string is injected from library input.
if (!enumMethods.includes(method)) {
throw new Error('[http-router] Method not allowed');
}
// remove trailing slash, but not if it's the first one
if (path.endsWith('/') && path !== '/') {
path = path.substr(0, path.length - 1);
}
// Static
if (path.indexOf('{') < 0) {

@@ -19,2 +22,3 @@ attachStaticRoute(method, path, handler, routesStatic);

}
// Dynamic
attachDynamicRoute(method, path, handler, routesDynamic);

@@ -27,2 +31,3 @@ }

}
// Static
const handler = routesStatic[method]?.[path];

@@ -32,2 +37,3 @@ if (typeof handler !== 'undefined') {

}
// Dynamic
for (const route of routesDynamic[method] ?? []){

@@ -43,2 +49,3 @@ const match = path.match(route.path);

}
// Not Found
throw createError(404, 'Route does not exist');

@@ -57,3 +64,4 @@ };

'HEAD'
];
] // ANY excluded by design
;
const attachStaticRoute = (method, path, handler, routesType)=>{

@@ -70,3 +78,4 @@ if (method === 'ANY') {

routesType[method][path] = handler;
routesType[method][path + '/'] = handler;
routesType[method][path + '/'] = handler // Optional `/`
;
};

@@ -84,3 +93,4 @@ const attachDynamicRoute = (method, path, handler, routesType)=>{

path = path.replace(regexpDynamicWildcards, '/?(?<$1>.*)').replace(regexpDynamicParameters, '/(?<$1>[^/]+)');
path = new RegExp(`^${path}/?$`);
path = new RegExp(`^${path}/?$`) // Adds in optional `/`
;
routesType[method].push({

@@ -92,2 +102,3 @@ path,

const pickVersion = (event)=>{
// '1.0' is a safer default
return event.version ?? (event.method ? 'vpc' : '1.0');

@@ -94,0 +105,0 @@ };

8

package.json
{
"name": "@middy/http-router",
"version": "4.6.1",
"version": "4.6.2",
"description": "HTTP event router for the middy framework",

@@ -69,9 +69,9 @@ "type": "module",

"dependencies": {
"@middy/util": "4.6.1"
"@middy/util": "4.6.2"
},
"devDependencies": {
"@middy/core": "4.6.1",
"@middy/core": "4.6.2",
"@types/aws-lambda": "^8.10.97"
},
"gitHead": "253ed0e4ca95623decbade03938a07d837a1eba2"
"gitHead": "8b03a01abf5a9c08231ec5ced775e87f8be8f67d"
}

Sorry, the diff of this file is not supported yet

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