Skip to content

Commit 913b64b

Browse files
Support for ES5
1 parent 4e73555 commit 913b64b

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

lib-es5/api_client/execute_request.js

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
'use strict';
22

3+
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
4+
35
// eslint-disable-next-line import/order
46
var config = require("../config");
57
var https = /^http:/.test(config().upload_prefix) ? require('http') : require('https');
@@ -74,12 +76,19 @@ function execute_request(method, params, auth, api_url, callback) {
7476
request_options.headers['Content-Length'] = Buffer.byteLength(query_params);
7577
}
7678
handle_response = function handle_response(res) {
77-
const {hide_sensitive = false} = config();
78-
const sanitized_request_options = {...request_options};
79+
var _config = config(),
80+
_config$hide_sensitiv = _config.hide_sensitive,
81+
hide_sensitive = _config$hide_sensitiv === undefined ? false : _config$hide_sensitiv;
82+
83+
var sanitized_request_options = _extends({}, request_options);
7984

80-
if (hide_sensitive === true){
81-
if ("auth" in sanitized_request_options) { delete sanitized_request_options.auth; }
82-
if ("Authorization" in sanitized_request_options.headers) { delete sanitized_request_options.headers.Authorization; }
85+
if (hide_sensitive === true) {
86+
if ("auth" in sanitized_request_options) {
87+
delete sanitized_request_options.auth;
88+
}
89+
if ("Authorization" in sanitized_request_options.headers) {
90+
delete sanitized_request_options.headers.Authorization;
91+
}
8392
}
8493

8594
if (includes([200, 400, 401, 403, 404, 409, 420, 500], res.statusCode)) {
@@ -149,7 +158,7 @@ function execute_request(method, params, auth, api_url, callback) {
149158
request_options: sanitized_request_options,
150159
query_params,
151160
hide_sensitive
152-
}
161+
}
153162
};
154163
deferred.reject(err_obj.error);
155164
if (typeof callback === "function") {

0 commit comments

Comments
 (0)