mirror of
https://github.com/Kong/insomnia.git
synced 2026-10-27 17:19:42 -04:00
* Pull out some render utils into functions * Added some tests for lib functions * strict refs
20 lines
494 B
JavaScript
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;
|
|
}
|