Socket
Socket
Sign inDemoInstall

toxy

Package Overview
Dependencies
30
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.3.3 to 0.3.4

9

lib/rules/response-status.js

@@ -15,2 +15,3 @@ module.exports = function responseStatus(opts) {

var range = opts.range || [200, 300]
var include = opts.include

@@ -25,2 +26,6 @@ return function responseStatus(req, res, next) {

if (lower && higher) {
return next(null, !(status < lower && status > higher))
}
if (lower) {

@@ -34,2 +39,6 @@ return next(null, !(status < lower))

if (include) {
return next(null, !~include.indexOf(status))
}
return next(null, !inRange(status))

@@ -36,0 +45,0 @@ }

2

package.json
{
"name": "toxy",
"version": "0.3.3",
"version": "0.3.4",
"description": "Hackable HTTP proxy to simulate server failure scenarios and unexpected network conditions",

@@ -5,0 +5,0 @@ "repository": "h2non/toxy",

@@ -792,6 +792,13 @@ # toxy [![Build Status](https://api.travis-ci.org/h2non/toxy.svg?branch=master&style=flat)](https://travis-ci.org/h2non/toxy) [![Code Climate](https://codeclimate.com/github/h2non/toxy/badges/gpa.svg)](https://codeclimate.com/github/h2non/toxy) [![NPM](https://img.shields.io/npm/v/toxy.svg)](https://www.npmjs.org/package/toxy)

- **value** `number` - Status code to match using a strict equality comparison. Default `null`.
- **include** `array` - Unordered list of status codes to match. Useful to specify custom status. Default `null`
```js
var rule = toxy.rules.contentType('application/json')
toxy.rule(rule)
// Strict evaluation of the status code
toxy.rule(toxy.rules.responseBody(200))
// Using a range of valid status
toxy.rule(toxy.rules.responseBody([200, 204]))
// Using relational comparison
toxy.rule(toxy.rules.responseBody({ higher: 199, lower: 400 }))
// Custom unordered status code to match
toxy.rule(toxy.rules.responseBody({ include: [200, 204, 400, 404] }))
```

@@ -798,0 +805,0 @@

@@ -37,2 +37,9 @@ const expect = require('chai').expect

})
test('include', function () {
assert({ include: [204] }, 204, equals(false))
assert({ include: [201] }, 200, equals(true))
assert({ include: [204, 400, 200] }, 200, equals(false))
assert({ include: [] }, 200, equals(true))
})
})

@@ -39,0 +46,0 @@

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc