Browse Source

use `safe-buffer` (#253)

extract-response
Dmitry Tsvettsikh 8 years ago
committed by Vsevolod Strukchinsky
parent
commit
53b11e3539
  1. 1
      .travis.yml
  2. 11
      index.js
  3. 1
      package.json

1
.travis.yml

@ -4,4 +4,5 @@ node_js:
- '6'
- '5'
- '4'
- '4.4.4'
after_success: npm run coveralls

11
index.js

@ -15,14 +15,9 @@ const isRedirect = require('is-redirect');
const unzipResponse = require('unzip-response');
const createErrorClass = require('create-error-class');
const isRetryAllowed = require('is-retry-allowed');
const Buffer = require('safe-buffer').Buffer;
const pkg = require('./package');
const isModernBuffer = (
typeof Buffer.alloc === 'function' &&
typeof Buffer.allocUnsafe === 'function' &&
typeof Buffer.from === 'function'
);
function requestAsEventEmitter(opts) {
opts = opts || {};
@ -46,9 +41,7 @@ function requestAsEventEmitter(opts) {
return;
}
const bufferString = isModernBuffer ?
Buffer.from(res.headers.location, 'binary').toString() :
new Buffer(res.headers.location, 'binary').toString();
const bufferString = Buffer.from(res.headers.location, 'binary').toString();
redirectUrl = urlLib.resolve(urlLib.format(opts), bufferString);
const redirectOpts = Object.assign({}, opts, urlLib.parse(redirectUrl));

1
package.json

@ -52,6 +52,7 @@
"is-retry-allowed": "^1.0.0",
"is-stream": "^1.0.0",
"lowercase-keys": "^1.0.0",
"safe-buffer": "^5.0.1",
"timed-out": "^3.0.0",
"unzip-response": "^2.0.1",
"url-parse-lax": "^1.0.0"

Loading…
Cancel
Save