New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

fake-xml-http-request

Package Overview
Dependencies
Maintainers
3
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fake-xml-http-request - npm Package Compare versions

Comparing version 1.4.0 to 1.5.0

10

fake_xml_http_request.js

@@ -275,3 +275,11 @@ (function (global, factory) {

if (!/^(get|head)$/i.test(this.method)) {
if (!this.requestHeaders["Content-Type"] && !(data || '').toString().match('FormData')) {
var hasContentTypeHeader = false
Object.keys(this.requestHeaders).forEach(function (key) {
if (key.toLowerCase() === 'content-type') {
hasContentTypeHeader = true;
}
});
if (!hasContentTypeHeader && !(data || '').toString().match('FormData')) {
this.requestHeaders["Content-Type"] = "text/plain;charset=UTF-8";

@@ -278,0 +286,0 @@ }

13

package.json
{
"name": "fake-xml-http-request",
"version": "1.4.0",
"version": "1.5.0",
"description": "test infrastructure for a fake XMLHttpRequest object",

@@ -17,8 +17,9 @@ "main": "fake_xml_http_request.js",

"esperanto": "^0.6.15",
"karma": "~0.12.31",
"karma-chrome-launcher": "~0.1.7",
"karma-firefox-launcher": "~0.1.4",
"karma-phantomjs-launcher": "~0.1.4",
"karma-qunit": "~0.1.4"
"karma": "^1.6.0",
"karma-chrome-launcher": "^2.0.0",
"karma-firefox-launcher": "^1.0.1",
"karma-phantomjs-launcher": "^1.0.4",
"karma-qunit": "^1.2.1",
"qunitjs": "^1.0.0"
}
}

@@ -269,3 +269,11 @@ /**

if (!/^(get|head)$/i.test(this.method)) {
if (!this.requestHeaders["Content-Type"] && !(data || '').toString().match('FormData')) {
var hasContentTypeHeader = false
Object.keys(this.requestHeaders).forEach(function (key) {
if (key.toLowerCase() === 'content-type') {
hasContentTypeHeader = true;
}
});
if (!hasContentTypeHeader && !(data || '').toString().match('FormData')) {
this.requestHeaders["Content-Type"] = "text/plain;charset=UTF-8";

@@ -272,0 +280,0 @@ }

@@ -18,3 +18,3 @@ var xhr;

test("does not change Content-Type if explicitly set for non-GET/HEAD", function(){
test("does not change Content-Type if explicitly set for non-GET/HEAD using key Content-TYpe", function(){
xhr.open("POST", "/");

@@ -27,2 +27,22 @@ xhr.setRequestHeader("Content-Type", "application/json");

test("does not set Content-Type if content-type explicitly set for non-GET/HEAD", function(){
xhr.open("POST", "/");
xhr.setRequestHeader("content-type", "application/json");
xhr.send("data");
equal(xhr.requestHeaders["content-type"], "application/json",
"does not change existing content-type header");
equal(xhr.requestHeaders["Content-Type"], undefined,
"does not add Content-Type header");
});
test("does not set Content-Type if CoNtEnT-tYpE explicitly set for non-GET/HEAD", function(){
xhr.open("POST", "/");
xhr.setRequestHeader("CoNtEnT-tYpE", "application/json");
xhr.send("data");
equal(xhr.requestHeaders["CoNtEnT-tYpE"], "application/json",
"does not change existing content-type header");
equal(xhr.requestHeaders["Content-Type"], undefined,
"does not add Content-Type header");
});
test("does not set Content-Type if data is FormData object", function(){

@@ -29,0 +49,0 @@ xhr.open("POST", "/");

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