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

headers-polyfill

Package Overview
Dependencies
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

headers-polyfill - npm Package Compare versions

Comparing version 3.2.4 to 3.2.5

8

lib/index.d.ts

@@ -17,2 +17,6 @@ declare type HeadersList = Array<[string, string | string[]]>;

/**
* Returns a boolean stating whether a `Headers` object contains a certain header.
*/
has(name: string): boolean;
/**
* Returns a `ByteString` sequence of all the values of a header with a given name.

@@ -42,6 +46,2 @@ */

/**
* Returns a boolean stating whether a `Headers` object contains a certain header.
*/
has(name: string): boolean;
/**
* Traverses the `Headers` object,

@@ -48,0 +48,0 @@ * calling the given callback for each header.

@@ -436,17 +436,74 @@ function _array_like_to_array(arr, len) {

function normalizeHeaderName(name) {
if (typeof name !== "string") {
name = String(name);
}
if (HEADERS_INVALID_CHARACTERS.test(name) || name.trim() === "") {
throw new TypeError("Invalid character in header field name");
}
return name.toLowerCase();
return name.trim().toLowerCase();
}
// src/utils/normalizeHeaderValue.ts
var charCodesToRemove = [
String.fromCharCode(10),
String.fromCharCode(13),
String.fromCharCode(9),
String.fromCharCode(32)
];
var HEADER_VALUE_REMOVE_REGEXP = new RegExp("(^[".concat(charCodesToRemove.join(""), "]|$[").concat(charCodesToRemove.join(""), "])"), "g");
function normalizeHeaderValue(value) {
var nextValue = value.replace(HEADER_VALUE_REMOVE_REGEXP, "");
return nextValue;
}
// src/utils/isValidHeaderName.ts
function isValidHeaderName(value) {
if (typeof value !== "string") {
value = String(value);
return false;
}
return value;
if (value.length === 0) {
return false;
}
for(var i = 0; i < value.length; i++){
var character = value.charCodeAt(i);
if (character > 127 || !isToken(character)) {
return false;
}
}
return true;
}
function isToken(value) {
return ![
127,
32,
"(",
")",
"<",
">",
"@",
",",
";",
":",
"\\",
'"',
"/",
"[",
"]",
"?",
"=",
"{",
"}"
].includes(value);
}
// src/utils/isValidHeaderValue.ts
function isValidHeaderValue(value) {
if (typeof value !== "string") {
return false;
}
if (value.trim() !== value) {
return false;
}
for(var i = 0; i < value.length; i++){
var character = value.charCodeAt(i);
if (character === 0 || character === 10 || character === 13) {
return false;
}
}
return true;
}
// src/Headers.ts

@@ -781,4 +838,16 @@ var NORMALIZED_HEADERS = Symbol("normalizedHeaders");

{
key: "has",
value: function has(name) {
if (!isValidHeaderName(name)) {
throw new TypeError('Invalid header name "'.concat(name, '"'));
}
return this[NORMALIZED_HEADERS].hasOwnProperty(normalizeHeaderName(name));
}
},
{
key: "get",
value: function get(name) {
if (!isValidHeaderName(name)) {
throw TypeError('Invalid header name "'.concat(name, '"'));
}
var _this_NORMALIZED_HEADERS_normalizeHeaderName;

@@ -791,4 +860,8 @@ return (_this_NORMALIZED_HEADERS_normalizeHeaderName = this[NORMALIZED_HEADERS][normalizeHeaderName(name)]) !== null && _this_NORMALIZED_HEADERS_normalizeHeaderName !== void 0 ? _this_NORMALIZED_HEADERS_normalizeHeaderName : null;

value: function set(name, value) {
if (!isValidHeaderName(name) || !isValidHeaderValue(value)) {
return;
}
var normalizedName = normalizeHeaderName(name);
this[NORMALIZED_HEADERS][normalizedName] = normalizeHeaderValue(value);
var normalizedValue = normalizeHeaderValue(value);
this[NORMALIZED_HEADERS][normalizedName] = normalizeHeaderValue(normalizedValue);
this[RAW_HEADER_NAMES].set(normalizedName, name);

@@ -800,4 +873,8 @@ }

value: function append(name, value) {
if (!isValidHeaderName(name) || !isValidHeaderValue(value)) {
return;
}
var normalizedName = normalizeHeaderName(name);
var resolvedValue = this.has(normalizedName) ? "".concat(this.get(normalizedName), ", ").concat(value) : value;
var normalizedValue = normalizeHeaderValue(value);
var resolvedValue = this.has(normalizedName) ? "".concat(this.get(normalizedName), ", ").concat(normalizedValue) : normalizedValue;
this.set(name, resolvedValue);

@@ -809,2 +886,5 @@ }

value: function _delete(name) {
if (!isValidHeaderName(name)) {
return;
}
if (!this.has(name)) {

@@ -852,8 +932,2 @@ return;

{
key: "has",
value: function has(name) {
return this[NORMALIZED_HEADERS].hasOwnProperty(normalizeHeaderName(name));
}
},
{
key: "forEach",

@@ -860,0 +934,0 @@ value: function forEach(callback, thisArg) {

{
"name": "headers-polyfill",
"version": "3.2.4",
"version": "3.2.5",
"description": "A native \"Headers\" class polyfill.",

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

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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