diff --git a/ui-v2/app/utils/http/create-headers.js b/ui-v2/app/utils/http/create-headers.js index 4b0280170d..43f30094c6 100644 --- a/ui-v2/app/utils/http/create-headers.js +++ b/ui-v2/app/utils/http/create-headers.js @@ -1,9 +1,9 @@ export default function() { return function(lines) { return lines.reduce(function(prev, item) { - const temp = item.split(':'); - if (temp.length > 1) { - prev[temp[0].trim()] = temp[1].trim(); + const [key, ...value] = item.split(':'); + if (value.length > 0) { + prev[key.trim()] = value.join(':').trim(); } return prev; }, {}); diff --git a/ui-v2/tests/unit/utils/http/create-headers-test.js b/ui-v2/tests/unit/utils/http/create-headers-test.js index 00ea967183..b421f2c0b4 100644 --- a/ui-v2/tests/unit/utils/http/create-headers-test.js +++ b/ui-v2/tests/unit/utils/http/create-headers-test.js @@ -15,4 +15,16 @@ module('Unit | Utility | http/create-headers', function() { const actual = parseHeaders(lines); assert.deepEqual(actual, expected); }); + test('it parses header values with colons correctly', function(assert) { + const expected = { + 'Content-Type': 'application/json', + 'X-Consul-Index': '1:2:3', + }; + const lines = ` + Content-Type: application/json + X-Consul-Index: 1:2:3 + `.split('\n'); + const actual = parseHeaders(lines); + assert.deepEqual(actual, expected); + }); });