mirror of
https://github.com/hashicorp/vault-action.git
synced 2025-11-14 18:13:45 +00:00
switch to more generic map solution for headers
This commit is contained in:
parent
018cad6aa5
commit
02f1f5a197
1 changed files with 11 additions and 5 deletions
16
action.js
16
action.js
|
|
@ -242,12 +242,18 @@ function parseHeadersInput(inputKey, inputOptions) {
|
||||||
.split('\n')
|
.split('\n')
|
||||||
.map(line => line.trim())
|
.map(line => line.trim())
|
||||||
.filter(line => line !== '');
|
.filter(line => line !== '');
|
||||||
const pairs = headerStrings
|
return headerStrings
|
||||||
.map(line => {
|
.reduce((map, line) => {
|
||||||
const seperator = line.indexOf(':');
|
const seperator = line.indexOf(':');
|
||||||
return [line.substring(0, seperator), line.substring(seperator + 1)];
|
const key = line.substring(0, seperator).trim().toLowerCase();
|
||||||
});
|
const value = line.substring(seperator + 1).trim();
|
||||||
return new Headers(pairs);
|
if (map.has(key)) {
|
||||||
|
map.set(key, [map.get(key), value].join(', '));
|
||||||
|
} else {
|
||||||
|
map.set(key, value);
|
||||||
|
}
|
||||||
|
return map;
|
||||||
|
}, new Map());
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue