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

vi-fetch

Package Overview
Dependencies
Maintainers
1
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vi-fetch - npm Package Compare versions

Comparing version 0.3.2 to 0.3.3

25

dist/headers.js
import "./chunk-JUWXSDKJ.js";
function normalizeName(name) {
if (typeof name !== "string") {
name = String(name);
}
if (/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(name) || name === "") {
throw new TypeError('Invalid character in header field name: "' + name + '"');
}
return name.toLowerCase();
}
class HeadersMock {

@@ -8,27 +17,27 @@ headers = /* @__PURE__ */ new Map();

if (Array.isArray(init)) {
init.forEach(([key, name]) => this.headers.set(key, name));
init.forEach(([key, name]) => this.headers.set(normalizeName(key), String(name)));
return;
}
if (init instanceof HeadersMock || typeof Headers !== "undefined" && init instanceof Headers) {
init.forEach((key, name) => this.headers.set(key, name));
init.forEach((value, key) => this.headers.set(normalizeName(key), String(value)));
return;
}
for (const key in init) {
this.headers.set(key, String(init[key]));
this.headers.set(normalizeName(key), String(init[key]));
}
}
append(name, value) {
this.headers.set(name, value);
this.headers.set(normalizeName(name), String(value));
}
delete(name) {
this.headers.delete(name);
this.headers.delete(normalizeName(name));
}
get(name) {
return this.headers.get(name) ?? null;
return this.headers.get(normalizeName(name)) ?? null;
}
has(name) {
return this.headers.has(name);
return this.headers.has(normalizeName(name));
}
set(name, value) {
this.headers.set(name, value);
this.headers.set(normalizeName(name), String(value));
}

@@ -35,0 +44,0 @@ forEach(callbackfn, thisArg) {

{
"name": "vi-fetch",
"version": "0.3.2",
"version": "0.3.3",
"description": "Easiest way to mock fetch",

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

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