From 02f1f5a197ae42fa241cd6c7b5093a04d6c3cbc5 Mon Sep 17 00:00:00 2001 From: Richard Simpson Date: Wed, 11 Mar 2020 14:00:33 -0500 Subject: [PATCH] switch to more generic map solution for headers --- action.js | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/action.js b/action.js index c16373b..4745e61 100644 --- a/action.js +++ b/action.js @@ -242,12 +242,18 @@ function parseHeadersInput(inputKey, inputOptions) { .split('\n') .map(line => line.trim()) .filter(line => line !== ''); - const pairs = headerStrings - .map(line => { + return headerStrings + .reduce((map, line) => { const seperator = line.indexOf(':'); - return [line.substring(0, seperator), line.substring(seperator + 1)]; - }); - return new Headers(pairs); + const key = line.substring(0, seperator).trim().toLowerCase(); + const value = line.substring(seperator + 1).trim(); + if (map.has(key)) { + map.set(key, [map.get(key), value].join(', ')); + } else { + map.set(key, value); + } + return map; + }, new Map()); } module.exports = {