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

messy

Package Overview
Dependencies
Maintainers
4
Versions
73
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

messy - npm Package Compare versions

Comparing version 6.11.0 to 6.12.0

37

lib/Headers.js

@@ -7,2 +7,3 @@ var foldHeaderLine = require('./foldHeaderLine'),

function Headers(obj, doNotStringify) {
this.namesWithCase = {};
this.valuesByName = {};

@@ -122,2 +123,5 @@ this.populate(obj, doNotStringify);

headerNameLowerCase = headerName.toLowerCase();
this.namesWithCase[headerNameLowerCase] = headerName;
if (Array.isArray(value)) {

@@ -137,2 +141,3 @@ if (!doNotStringify) {

delete this.valuesByName[headerNameLowerCase];
delete this.namesWithCase[headerNameLowerCase];
} else {

@@ -168,2 +173,8 @@ if (!doNotStringify) {

Headers.prototype.getNames = function () {
return Object.keys(this.valuesByName).map(function (lowerCaseHeaderName) {
return this.namesWithCase[lowerCaseHeaderName];
}, this);
};
Headers.prototype.getNamesLowerCase = function () {
return Object.keys(this.valuesByName);

@@ -188,2 +199,3 @@ };

var headerNameLowerCase = headerName.toLowerCase();
this.namesWithCase[headerNameLowerCase] = headerName;
if (Array.isArray(valueOrValues)) {

@@ -195,2 +207,3 @@ if (typeof valueNumber !== 'undefined') {

delete this.valuesByName[headerNameLowerCase];
delete this.namesWithCase[headerNameLowerCase];
} else {

@@ -223,2 +236,3 @@ this.valuesByName[headerNameLowerCase] = valueOrValues.map(function (value) {

delete this.valuesByName[headerNameLowerCase];
delete this.namesWithCase[headerNameLowerCase];
return values.length;

@@ -233,2 +247,3 @@ } else if (Array.isArray(valueOrValuesOrValueNumber)) {

delete this.valuesByName[headerNameLowerCase];
delete this.namesWithCase[headerNameLowerCase];
numRemoved = 1;

@@ -245,2 +260,3 @@ } else if (valueOrValuesOrValueNumber < values.length) {

delete this.valuesByName[headerNameLowerCase];
delete this.namesWithCase[headerNameLowerCase];
} else {

@@ -335,4 +351,4 @@ values.splice(index, 1);

}
var headerNames = this.getNames(),
otherHeaderNames = other.getNames();
var headerNames = this.getNamesLowerCase(),
otherHeaderNames = other.getNamesLowerCase();
if (headerNames.length !== otherHeaderNames.length) {

@@ -371,4 +387,5 @@ return false;

Headers.prototype.clone = function () {
var clone = new Headers();
this.getNames().forEach(function (headerName) {
var clone = new Headers(),
lowerCaseHeaderNames = this.getNamesLowerCase();
lowerCaseHeaderNames.forEach(function (headerName) {
clone.set(headerName, this.getAll(headerName));

@@ -381,3 +398,3 @@ }, this);

var result = '',
lowerCaseHeaderNames = this.getNames();
lowerCaseHeaderNames = this.getNamesLowerCase();
lowerCaseHeaderNames.forEach(function (lowerCaseHeaderName) {

@@ -392,4 +409,5 @@ this.valuesByName[lowerCaseHeaderName].forEach(function (value) {

Headers.prototype.toCanonicalObject = function () {
var canonicalObject = {};
this.getNames().forEach(function (lowerCaseHeaderName) {
var canonicalObject = {},
lowerCaseHeaderNames = this.getNamesLowerCase();
lowerCaseHeaderNames.forEach(function (lowerCaseHeaderName) {
canonicalObject[formatHeaderName(lowerCaseHeaderName)] = this.getAll(lowerCaseHeaderName);

@@ -401,4 +419,5 @@ }, this);

Headers.prototype.toJSON = function () {
var obj = {};
this.getNames().forEach(function (lowerCaseHeaderName) {
var obj = {},
lowerCaseHeaderNames = this.getNamesLowerCase();
lowerCaseHeaderNames.forEach(function (lowerCaseHeaderName) {
var values = this.getAll(lowerCaseHeaderName);

@@ -405,0 +424,0 @@ if (values.length === 1) {

var HttpExchange = require('./HttpExchange');
function HttpConversation(obj) {
function HttpConversation(obj, doNotStringify) {
obj = obj || {};

@@ -9,3 +9,3 @@ this.exchanges = (obj.exchanges || []).map(function (httpExchange) {

} else {
return new HttpExchange(httpExchange);
return new HttpExchange(httpExchange, doNotStringify);
}

@@ -12,0 +12,0 @@ });

var HttpRequest = require('./HttpRequest'),
HttpResponse = require('./HttpResponse');
function HttpExchange(obj) {
function HttpExchange(obj, doNotStringify) {
obj = obj || {};
if (typeof obj.request !== 'undefined') {
this.request = obj.request instanceof HttpRequest ? obj.request : new HttpRequest(obj.request);
this.request = obj.request instanceof HttpRequest ? obj.request : new HttpRequest(obj.request, doNotStringify);
}
if (typeof obj.response !== 'undefined') {
this.response = obj.response instanceof HttpResponse ? obj.response : new HttpResponse(obj.response);
this.response = obj.response instanceof HttpResponse ? obj.response : new HttpResponse(obj.response, doNotStringify);
}

@@ -12,0 +12,0 @@ }

@@ -7,3 +7,3 @@ /*global btoa*/

function HttpRequest(obj) {
function HttpRequest(obj, doNotStringify) {
this.requestLine = new RequestLine();

@@ -10,0 +10,0 @@ this.encrypted = false;

@@ -6,5 +6,5 @@ var Message = require('./Message'),

function HttpResponse(obj) {
function HttpResponse(obj, doNotStringify) {
this.statusLine = new StatusLine();
Message.call(this, obj);
Message.call(this, obj, doNotStringify);
}

@@ -11,0 +11,0 @@

@@ -21,5 +21,5 @@ /*global unescape, btoa, atob, JSON*/

function Message(obj) {
function Message(obj, doNotStringify) {
this.headers = new this.HeadersConstructor();
this.populate(obj);
this.populate(obj, doNotStringify);
}

@@ -26,0 +26,0 @@

{
"name": "messy",
"version": "6.11.0",
"version": "6.12.0",
"description": "Object model for HTTP and RFC822 messages",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

@@ -54,2 +54,10 @@ /*global describe, it*/

it('should return the header names in their original case', function () {
expect(new Headers({'X-in-ORIGNAL-Case': 'baz'}).getNames(), 'to equal', ['X-in-ORIGNAL-Case']);
});
it('should return lower case header names when requested', function () {
expect(new Headers({'X-in-ORIGNAL-Case': 'baz'}).getNamesLowerCase(), 'to equal', ['x-in-orignal-case']);
});
describe('#remove', function () {

@@ -56,0 +64,0 @@ it('should remove all header values for the given header when only passed one argument', function () {

@@ -26,3 +26,4 @@ /*global describe, it*/

var message = new Message('From: thisguy@example.com\r\nTo: thisotherguy@example.com');
expect(message.headers.getNames(), 'to equal', ['from', 'to']);
expect(message.headers.getNames(), 'to equal', ['From', 'To']);
expect(message.headers.getNamesLowerCase(), 'to equal', ['from', 'to']);
});

@@ -125,3 +126,4 @@

expect(message.headers.getNames(), 'to equal', ['content-type', 'content-transfer-encoding', 'subject', 'from', 'message-id', 'date', 'to', 'mime-version']);
expect(message.headers.getNames(), 'to equal', ['Content-Type', 'Content-Transfer-Encoding', 'Subject', 'From', 'Message-Id', 'Date', 'To', 'Mime-Version']);
expect(message.headers.getNamesLowerCase(), 'to equal', ['content-type', 'content-transfer-encoding', 'subject', 'from', 'message-id', 'date', 'to', 'mime-version']);
expect(message.headers.get('Content-Type'), 'to equal', 'multipart/mixed;\tboundary=Apple-Mail-589ECA5D-7F89-4C39-B7B7-7FD03E6333CD');

@@ -128,0 +130,0 @@ expect(message.headers.get('content-transfer-encoding'), 'to equal', '7bit');

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