forked from TryGhost/framework
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed incoming request header casing issue
refs https://github.com/TryGhost/Toolbox/issues/209 refs antongolub/reqresnext#33 - All request headers should be lowercased to match the default behavior in express and node's http module. These patches should be removed once the upstream issue is solved
- Loading branch information
Showing
3 changed files
with
32 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,27 @@ | ||
const {assert} = require('./utils'); | ||
|
||
const {isJSON} = require('../lib/utils'); | ||
const {isJSON, convertKeysToLowerCase} = require('../lib/utils'); | ||
|
||
describe('Utils', function () { | ||
it('isJSON', function () { | ||
assert.equal(isJSON('application/json'), true); | ||
assert.equal(isJSON('application/ld+json'), true); | ||
assert.equal(isJSON('text/html'), false); | ||
}); | ||
|
||
it('convertKeysToLowerCase', function () { | ||
const map = { | ||
prop: 'value', | ||
standard_Notation: 42, | ||
'BaZ-Header': 'qux' | ||
}; | ||
|
||
const lowerCasedMap = convertKeysToLowerCase(map); | ||
|
||
assert.equal(map.standard_Notation, 42, 'original map is not modified'); | ||
|
||
assert.equal(lowerCasedMap.prop, 'value'); | ||
assert.equal(lowerCasedMap.standard_notation, 42); | ||
assert.equal(lowerCasedMap['baz-header'], 'qux'); | ||
}); | ||
}); |