http-browserify
Advanced tools
Comparing version 1.6.0 to 1.7.0
@@ -145,2 +145,5 @@ var Stream = require('stream'); | ||
} | ||
else if (isXHR2Compatible(this.body[0])) { | ||
this.xhr.send(this.body[0]); | ||
} | ||
else { | ||
@@ -202,1 +205,7 @@ var body = ''; | ||
}; | ||
var isXHR2Compatible = function (obj) { | ||
if (typeof Blob !== 'undefined' && obj instanceof Blob) return true; | ||
if (typeof ArrayBuffer !== 'undefined' && obj instanceof ArrayBuffer) return true; | ||
if (typeof FormData !== 'undefined' && obj instanceof FormData) return true; | ||
}; |
{ | ||
"name": "http-browserify", | ||
"version": "1.6.0", | ||
"version": "1.7.0", | ||
"description": "http module compatability for browserify", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -1,11 +0,10 @@ | ||
global.window = { | ||
location: { | ||
global.window = global; | ||
global.location = { | ||
host: 'localhost:8081', | ||
port: 8081, | ||
protocol: 'http:' | ||
} | ||
}; | ||
var noop = function() {}; | ||
global.window.XMLHttpRequest = function() { | ||
global.XMLHttpRequest = function() { | ||
this.open = noop; | ||
@@ -15,2 +14,6 @@ this.send = noop; | ||
global.FormData = function () {}; | ||
global.Blob = function () {}; | ||
global.ArrayBuffer = function () {}; | ||
var test = require('tape').test; | ||
@@ -90,1 +93,24 @@ var http = require('../index.js'); | ||
}); | ||
test('Test POST XHR2 types', function(t) { | ||
t.plan(3); | ||
var url = '/api/foo'; | ||
var request = http.request({ url: url, method: 'POST' }, noop); | ||
request.xhr.send = function (data) { | ||
t.ok(data instanceof global.ArrayBuffer, 'data should be instanceof ArrayBuffer'); | ||
}; | ||
request.end(new global.ArrayBuffer()); | ||
request = http.request({ url: url, method: 'POST' }, noop); | ||
request.xhr.send = function (data) { | ||
t.ok(data instanceof global.Blob, 'data should be instanceof Blob'); | ||
}; | ||
request.end(new global.Blob()); | ||
request = http.request({ url: url, method: 'POST' }, noop); | ||
request.xhr.send = function (data) { | ||
t.ok(data instanceof global.FormData, 'data should be instanceof FormData'); | ||
}; | ||
request.end(new global.FormData()); | ||
}); |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 2 instances in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Mixed license
License(Experimental) Package contains multiple licenses.
Found 1 instance in 1 package
0
132
0
5
24624
19
614