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

check_header

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

check_header - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

10

lib/headers.js

@@ -24,14 +24,14 @@ // From NodeJS - https://github.com/nodejs/node/commit/2a2d3e1b0333441d1bd00def06d687f807067f6e

// Get object with headers and return bool
function checkHeaders(headers) {
function isValid(headers) {
for (var property in headers) {
if (headers.hasOwnProperty(property)) {
if (checkInvalidHeaderChar(headers[property])===true) {
return true;
return false;
}
if (checkIsHttpToken(property)===false) {
return true;
return false;
}
}
}
return false;
return true;
}

@@ -42,3 +42,3 @@

checkIsHttpToken: checkIsHttpToken,
checkHeaders: checkHeaders
isValid: isValid
};
{
"name": "check_header",
"version": "1.0.0",
"version": "1.0.1",
"description": "Check if headers aren't invalid for correct use in setHeader or writeHead functions",

@@ -5,0 +5,0 @@ "main": "lib/",

@@ -1,1 +0,17 @@

# check_header
# Check Header
Code is inherit from NodeJS internal functions introduced in v0.10.42, v0.12.10, v4.3.1 and v5.6.0.
## Install
npm install check_header
## Example
var checker = require('check_header');
var headersObject = {'Content-Type':'žluťoučký kůň'};
if (checker.checkHeaders(headersObject)) {
console.log("Invalid header there!");
}

@@ -7,12 +7,12 @@ var assert = require('chai').assert;

var headersObject = {'Content-Type':'application/json'};
assert.equal(headers.checkHeaders(headersObject), false);
assert.equal(headers.isValid(headersObject), true);
});
it ('Check invalid header', function(){
var headersObject = {'Příliš':'žluťoučký kůň'};
assert.equal(headers.checkHeaders(headersObject), true);
assert.equal(headers.isValid(headersObject), false);
});
it ('Check invalid header', function(){
var headersObject = {'Content-Type':'žluťoučký kůň'};
assert.equal(headers.checkHeaders(headersObject), true);
assert.equal(headers.isValid(headersObject), false);
});
});
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