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

middie

Package Overview
Dependencies
Maintainers
2
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

middie - npm Package Compare versions

Comparing version 3.2.0 to 3.2.1

5

middie.js

@@ -103,3 +103,6 @@ 'use strict'

if (result) {
req.url = req.url.replace(result[0], '/')
req.url = req.url.replace(result[0], '')
if (req.url.startsWith('/') === false) {
req.url = '/' + req.url
}
fn(req, res, that.done)

@@ -106,0 +109,0 @@ } else {

2

package.json
{
"name": "middie",
"version": "3.2.0",
"version": "3.2.1",
"description": "Middleware engine for Fastify",

@@ -5,0 +5,0 @@ "main": "middie.js",

@@ -94,3 +94,3 @@ 'use strict'

test('run restricted by path', t => {
t.plan(9)
t.plan(11)

@@ -118,2 +118,7 @@ const instance = middie(function (err, a, b) {

t.equal(instance.use('/test', function (req, res, next) {
t.equal('/', req.url)
next()
}), instance)
t.equal(instance.use('/no-call', function (req, res, next) {

@@ -127,2 +132,66 @@ t.fail('should not call this function')

test('run restricted by path - prefix override', t => {
t.plan(10)
const instance = middie(function (err, a, b) {
t.error(err)
t.equal(a, req)
t.equal('/test/other/one', req.url)
t.equal(b, res)
})
const req = {
url: '/test/other/one'
}
const res = {}
t.equal(instance.use(function (req, res, next) {
t.ok('function called')
next()
}), instance)
t.equal(instance.use('/test', function (req, res, next) {
t.ok('function called')
next()
}), instance)
t.equal(instance.use('/test', function (req, res, next) {
t.equal('/other/one', req.url)
next()
}), instance)
instance.run(req, res)
})
test('run restricted by path - prefix override 2', t => {
t.plan(10)
const instance = middie(function (err, a, b) {
t.error(err)
t.equal(a, req)
t.equal('/tasks-api/task', req.url)
t.equal(b, res)
})
const req = {
url: '/tasks-api/task'
}
const res = {}
t.equal(instance.use(function (req, res, next) {
t.ok('function called')
next()
}), instance)
t.equal(instance.use('/tasks-api', function (req, res, next) {
t.ok('function called')
next()
}), instance)
t.equal(instance.use('/tasks-api', function (req, res, next) {
t.equal('/task', req.url)
next()
}), instance)
instance.run(req, res)
})
test('run restricted by array path', t => {

@@ -129,0 +198,0 @@ t.plan(9)

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