Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/fastboot-headers.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,14 @@ function FastBootHeaders(headers) {
this.headers = {};

for (var header in headers) {
this.headers[header] = headers[header].split(', ');
let value = headers[header];

// convert to array if not already
if (typeof value === 'string') {
value = value.split(', ');
}

this.headers[header] = value;
}
}

Expand Down
10 changes: 9 additions & 1 deletion test/fastboot-headers-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,15 @@ describe('FastBootHeaders', function() {
expect(headers.has('host')).to.be.false;
});

it('handles header values that are already an array', function() {
var headers = {
'x-test-header': ['value1', 'value2']
};
headers = new FastBootHeaders(headers);

expect(headers.getAll('x-test-header')).to.deep.equal(['value1', 'value2']);
});

it('appends entries onto a header, regardless of casing', function() {
var headers = new FastBootHeaders();

Expand Down Expand Up @@ -149,4 +158,3 @@ describe('FastBootHeaders', function() {
expect(entriesIterator.next()).to.deep.equal({ value: undefined, done: true });
});
});