Skip to content

Commit

Permalink
push new build afetr #22 merge
Browse files Browse the repository at this point in the history
  • Loading branch information
Dtphelan1 committed Dec 14, 2023
1 parent 9d800b6 commit 70430b4
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 9 deletions.
15 changes: 11 additions & 4 deletions built/lib/BulkDataClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,14 +133,21 @@ class BulkDataClient extends events_1.EventEmitter {
}
/**
* Internal method for formatting response headers for some emitted events
* based on `options.errorDebuggingHeaders`
* based on `options.logResponseHeaders`
* @param headers
* @returns responseHeaders
*/
formatResponseHeaders(headers) {
return (this.options.errorDebuggingHeaders === 'all'
? headers
: (0, utils_1.filterResponseHeaders)(headers, this.options.errorDebuggingHeaders));
if (this.options.logResponseHeaders.toString().toLocaleLowerCase() === 'none')
return undefined;
if (this.options.logResponseHeaders.toString().toLocaleLowerCase() === 'all')
return headers;
// If not an array it must be a string or a RegExp
if (!Array.isArray(this.options.logResponseHeaders)) {
return (0, utils_1.filterResponseHeaders)(headers, [this.options.logResponseHeaders]);
}
// Else it must be an array
return (0, utils_1.filterResponseHeaders)(headers, this.options.logResponseHeaders);
}
/**
* Get an access token to be used as bearer in requests to the server.
Expand Down
16 changes: 11 additions & 5 deletions built/lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const source_1 = require("got/dist/source");
const zlib_1 = __importDefault(require("zlib"));
const request_1 = __importDefault(require("./request"));
const stream_1 = require("stream");
const types_1 = require("util/types");
const debug = util_1.default.debuglog("app");
const HTTP_CACHE = new Map();
/**
Expand Down Expand Up @@ -372,7 +373,7 @@ exports.createDecompressor = createDecompressor;
* Filter a Headers object down to a selected series of headers
* @param headers The object of headers to filter
* @param selectedHeaders The headers that should remain post-filter
* @returns Types.ResponseHeaders | {}
* @returns Types.ResponseHeaders | {} | undefined
*/
function filterResponseHeaders(headers, selectedHeaders) {
// In the event the headers is undefined or null, just return undefined
Expand All @@ -381,10 +382,15 @@ function filterResponseHeaders(headers, selectedHeaders) {
// NOTE: If an empty array of headers is specified, return none of them
return Object
.entries(headers)
.reduce((headers, [key, value]) => {
if (!selectedHeaders.includes(key))
return headers;
return { ...headers, [key]: value };
.reduce((matchedHeaders, [key, value]) => {
// These are usually normalized to lowercase by most libraries, but just to be sure
const lowercaseKey = key.toLocaleLowerCase();
// Each selectedHeader is either a RegExp, where we check for matches via RegExp.test
// or a string, where we check for matches with equality
if (selectedHeaders.find((h) => (0, types_1.isRegExp)(h) ? h.test(lowercaseKey) : h.toLocaleLowerCase() === lowercaseKey))
return { ...matchedHeaders, [key]: value };
// If we don't find a selectedHeader that matches this header, we move on
return matchedHeaders;
}, {});
}
exports.filterResponseHeaders = filterResponseHeaders;

0 comments on commit 70430b4

Please sign in to comment.