Skip to content

Commit

Permalink
fix: protocolHeaders can split with whitespace (eggjs#164)
Browse files Browse the repository at this point in the history
  • Loading branch information
popomore authored and fengmk2 committed Dec 19, 2016
1 parent 3b43ed1 commit db614d4
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/extend/request.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ module.exports = {
}

if (typeof this.app.config.protocolHeaders === 'string' && this.app.config.protocolHeaders) {
const protocolHeaders = this.app.config.protocolHeaders.split(',');
const protocolHeaders = this.app.config.protocolHeaders.split(/\s*,\s*/);
for (const header of protocolHeaders) {
let proto = this.get(header);
if (proto) {
Expand Down
2 changes: 1 addition & 1 deletion test/app/extend/request.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ describe('test/app/extend/request.test.js', () => {
});

it('should return value of X-Custom-Proto', () => {
mm(app.config, 'protocolHeaders', 'X-Custom-Proto');
mm(app.config, 'protocolHeaders', 'X-Forwarded-Proto, X-Custom-Proto');
return request(app.callback())
.get('/protocol')
.set('X-Custom-Proto', 'https')
Expand Down

0 comments on commit db614d4

Please sign in to comment.