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

messy

Package Overview
Dependencies
Maintainers
3
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.8.1 to 6.9.0

34

lib/Headers.js

@@ -178,18 +178,24 @@ var foldHeaderLine = require('./foldHeaderLine'),

Headers.prototype.set = function (headerName, valueOrValues, valueNumber) {
var headerNameLowerCase = headerName.toLowerCase();
if (Array.isArray(valueOrValues)) {
if (typeof valueNumber !== 'undefined') {
throw new Error('Headers.set: valueNumber not supported when the values are provided as an array');
}
if (valueOrValues.length === 0) {
delete this.valuesByName[headerNameLowerCase];
if (headerName && typeof headerName === 'object') {
Object.keys(headerName).forEach(function (key) {
this.set(key, headerName[key]);
}, this);
} else {
var headerNameLowerCase = headerName.toLowerCase();
if (Array.isArray(valueOrValues)) {
if (typeof valueNumber !== 'undefined') {
throw new Error('Headers.set: valueNumber not supported when the values are provided as an array');
}
if (valueOrValues.length === 0) {
delete this.valuesByName[headerNameLowerCase];
} else {
this.valuesByName[headerNameLowerCase] = valueOrValues.map(function (value) {
return this.parseHeaderValue(value);
}, this);
}
} else if (typeof valueNumber === 'number' && Array.isArray(this.valuesByName[headerNameLowerCase]) && valueNumber < this.valuesByName[headerNameLowerCase].length) {
this.valuesByName[headerNameLowerCase][valueNumber] = this.parseHeaderValue(valueOrValues);
} else {
this.valuesByName[headerNameLowerCase] = valueOrValues.map(function (value) {
return this.parseHeaderValue(value);
}, this);
(this.valuesByName[headerNameLowerCase] = this.valuesByName[headerNameLowerCase] || []).push(this.parseHeaderValue(valueOrValues));
}
} else if (typeof valueNumber === 'number' && Array.isArray(this.valuesByName[headerNameLowerCase]) && valueNumber < this.valuesByName[headerNameLowerCase].length) {
this.valuesByName[headerNameLowerCase][valueNumber] = this.parseHeaderValue(valueOrValues);
} else {
(this.valuesByName[headerNameLowerCase] = this.valuesByName[headerNameLowerCase] || []).push(this.parseHeaderValue(valueOrValues));
}

@@ -196,0 +202,0 @@ };

{
"name": "messy",
"version": "6.8.1",
"version": "6.9.0",
"description": "Object model for HTTP and RFC822 messages",

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

@@ -149,2 +149,14 @@ /*global describe, it*/

});
describe('when passed an object', function () {
it('should act as a shorthand for calling set with each (key, value)', function () {
var headers = new Headers({foo: 'bar', baz: 'quux'});
headers.set({
foo: [ 'bar2' ],
baz: 'quux2',
yadda: 'blah'
});
expect(headers.toString(), 'to equal', 'Foo: bar2\r\nBaz: quux\r\nBaz: quux2\r\nYadda: blah\r\n');
});
});
});

@@ -151,0 +163,0 @@

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