simple-get
Advanced tools
Comparing version 3.0.3 to 3.1.0
@@ -18,3 +18,3 @@ module.exports = simpleGet | ||
if (opts.url) { | ||
const { hostname, port, protocol, auth, path } = url.parse(opts.url) | ||
const { hostname, port, protocol, auth, path } = url.parse(opts.url) // eslint-disable-line node/no-deprecated-api | ||
delete opts.url | ||
@@ -49,3 +49,3 @@ if (!hostname && !port && !protocol && !auth) opts.path = path // Relative redirect | ||
const req = protocol.request(opts, res => { | ||
if (res.statusCode >= 300 && res.statusCode < 400 && res.headers.location) { | ||
if (opts.followRedirects !== false && res.statusCode >= 300 && res.statusCode < 400 && res.headers.location) { | ||
opts.url = res.headers.location // Follow 3xx redirects | ||
@@ -98,5 +98,5 @@ delete opts.headers.host // Discard `host` header on redirect (see #32) | ||
simpleGet[method] = (opts, cb) => { | ||
if (typeof opts === 'string') opts = {url: opts} | ||
if (typeof opts === 'string') opts = { url: opts } | ||
return simpleGet(Object.assign({ method: method.toUpperCase() }, opts), cb) | ||
} | ||
}) |
{ | ||
"name": "simple-get", | ||
"description": "Simplest way to make http get requests. Supports HTTPS, redirects, gzip/deflate, streams in < 100 lines.", | ||
"version": "3.0.3", | ||
"version": "3.1.0", | ||
"author": { | ||
@@ -17,3 +17,3 @@ "name": "Feross Aboukhadijeh", | ||
"dependencies": { | ||
"decompress-response": "^3.3.0", | ||
"decompress-response": "^4.2.0", | ||
"once": "^1.3.1", | ||
@@ -25,3 +25,3 @@ "simple-concat": "^1.0.0" | ||
"standard": "*", | ||
"string-to-stream": "^1.0.0", | ||
"string-to-stream": "^3.0.0", | ||
"tape": "^4.0.0" | ||
@@ -28,0 +28,0 @@ }, |
@@ -244,2 +244,15 @@ # simple-get [![travis][travis-image]][travis-url] [![npm][npm-image]][npm-url] [![downloads][downloads-image]][downloads-url] [![javascript style guide][standard-image]][standard-url] | ||
### Specifically disallowing redirects | ||
```js | ||
const get = require('simple-get') | ||
const opts = { | ||
url: 'http://example.com/will-redirect-elsewhere', | ||
followRedirects: false | ||
} | ||
// res.statusCode will be 301, no error thrown | ||
get(opts, function (err, res) {}) | ||
``` | ||
### OAuth | ||
@@ -246,0 +259,0 @@ |
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
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
13161
320
+ Addeddecompress-response@4.2.1(transitive)
+ Addedmimic-response@2.1.0(transitive)
- Removeddecompress-response@3.3.0(transitive)
- Removedmimic-response@1.0.1(transitive)
Updateddecompress-response@^4.2.0