Socket
Socket
Sign inDemoInstall

@middy/http-router

Package Overview
Dependencies
1
Maintainers
3
Versions
100
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 5.0.2 to 5.0.3

17

index.js

@@ -8,3 +8,2 @@ 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)) {

@@ -17,7 +16,5 @@ throw new Error('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) {

@@ -27,3 +24,2 @@ attachStaticRoute(method, path, handler, routesStatic);

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

@@ -41,3 +37,2 @@ }

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

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

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

@@ -59,3 +53,2 @@ const match = path.match(route.path);

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

@@ -79,4 +72,3 @@ cause: {

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

@@ -93,4 +85,3 @@ if (method === 'ANY') {

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

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

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

@@ -117,3 +107,2 @@ path,

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

@@ -120,0 +109,0 @@ };

8

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

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

"dependencies": {
"@middy/util": "5.0.2"
"@middy/util": "5.0.3"
},
"devDependencies": {
"@middy/core": "5.0.2",
"@middy/core": "5.0.3",
"@types/aws-lambda": "^8.10.97"
},
"gitHead": "6d17e155237022f2a0abd095ac7cd99ebfc7fc71"
"gitHead": "87660575a7ac2b52e4153c407a4c63c9449dcd0d"
}
SocketSocket SOC 2 Logo

Product

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc