Socket
Socket
Sign inDemoInstall

node-fetch

Package Overview
Dependencies
Maintainers
1
Versions
96
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-fetch - npm Package Compare versions

Comparing version 1.0.4 to 1.0.5

9

CHANGELOG.md

@@ -8,4 +8,11 @@

## v1.0.4 (master)
## v1.0.5 (master)
- Fix: when follow = 0, fetch should not follow redirect
- Enhance: update tests for better coverage
- Enhance: code formatting
- Enhance: clean up doc
## v1.0.4
- Enhance: test iojs support

@@ -12,0 +19,0 @@ - Enhance: timeout attached to socket event only fire once per redirect

2

index.js

@@ -73,3 +73,3 @@

, headers: opts.headers || {}
, follow: opts.follow || 20
, follow: opts.follow !== undefined ? opts.follow : 20
, counter: opts.counter || 0

@@ -76,0 +76,0 @@ , timeout: opts.timeout || 0

@@ -22,11 +22,13 @@

for (var prop in headers) {
if (headers.hasOwnProperty(prop)) {
if (typeof headers[prop] === 'string') {
this.set(prop, headers[prop]);
} else if (headers[prop].length > 0) {
headers[prop].forEach(function(item) {
self.append(prop, item);
});
}
if (!headers.hasOwnProperty(prop)) {
continue;
}
if (typeof headers[prop] === 'string') {
this.set(prop, headers[prop]);
} else if (headers[prop].length > 0) {
headers[prop].forEach(function(item) {
self.append(prop, item);
});
}
}

@@ -33,0 +35,0 @@

{
"name": "node-fetch",
"version": "1.0.4",
"version": "1.0.5",
"description": "A light-weight module that brings window.fetch to node.js and io.js",

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

@@ -16,4 +16,2 @@

But I think the term [isomorphic](http://isomorphic.net/) is generally misleading: it gives developers a false sense of security that their javascript code will run happily on both controlled server environment as well as uncontrollable user browsers. When the latter is only true for a subset of modern browsers, not to mention quirks in native implementation.
Instead of implementing `XMLHttpRequest` in node to run browser-specific [fetch polyfill](https://github.com/github/fetch), why not go from node's `http` to `fetch` API directly? Node has native stream support, browserify build targets (browsers) don't, so underneath they are going to be vastly different anyway.

@@ -51,3 +49,3 @@

// If you are not on node v0.11, set a Promise library first, eg.
// If you are not on node v0.12, set a Promise library first, eg.
// fetch.Promise = require('bluebird');

@@ -147,4 +145,4 @@

, headers: {} // request header, format {a:1} or {b:[1,2,3]}
, follow: 20 // maximum redirect count, 0 to disable
, timeout: 0 // request timeout in ms, 0 to disable, note that redirect restart timeout
, follow: 20 // maximum redirect count, 0 to not follow redirect
, timeout: 0 // request timeout in ms, 0 to disable, timeout reset on redirect
, compress: true // support gzip/deflate content encoding, false to disable

@@ -151,0 +149,0 @@ , size: 0 // maximum response body size in bytes, 0 to disable

@@ -153,3 +153,2 @@

it('should follow redirect code 302', function() {

@@ -195,10 +194,2 @@ url = base + '/redirect/302';

it('should follow redirect chain', function() {
url = base + '/redirect/chain';
return fetch(url).then(function(res) {
expect(res.url).to.equal(base + '/inspect');
expect(res.status).to.equal(200);
});
});
it('should obey maximum redirect', function() {

@@ -212,2 +203,10 @@ url = base + '/redirect/chain';

it('should allow not following redirect', function() {
url = base + '/redirect/301';
opts = {
follow: 0
}
return expect(fetch(url, opts)).to.eventually.be.rejectedWith(Error);
});
it('should reject broken redirect', function() {

@@ -544,2 +543,16 @@ url = base + '/error/redirect';

it('should skip prototype when reading response headers', function() {
var FakeHeader = function() {};
FakeHeader.prototype.c = 'string';
FakeHeader.prototype.d = [1,2,3,4];
var res = new FakeHeader;
res.a = 'string';
res.b = [];
var headers = new Headers(res);
expect(headers._headers['a']).to.include('string');
expect(headers._headers['b']).to.be.undefined;
expect(headers._headers['c']).to.be.undefined;
expect(headers._headers['d']).to.be.undefined;
});
it('should support https request', function() {

@@ -546,0 +559,0 @@ this.timeout(5000);

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