Files
insomnia/app/lib/util.js
T
Gregory Schier 2ed92a7968 Actual Test Suite (#35)
* Pull out some render utils into functions

* Added some tests for lib functions

* strict refs
2016-09-02 21:32:45 -07:00

20 lines
494 B
JavaScript

export function getBasicAuthHeader (username, password) {
const name = 'Authorization';
const header = `${username || ''}:${password || ''}`;
const authString = new Buffer(header, 'utf8').toString('base64');
const value = `Basic ${authString}`;
return {name, value};
}
export function hasAuthHeader (headers) {
if (!Array.isArray(headers)) {
return false;
}
const index = headers.findIndex(
h => h.name.toLowerCase() === 'authorization'
);
return index !== -1;
}