Skip to content

Commit

Permalink
Hiding headers should be case insensitive
Browse files Browse the repository at this point in the history
  • Loading branch information
matthieubulte committed Jul 2, 2015
1 parent 6650bd2 commit b81a2a0
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Gruntfile.js
Expand Up @@ -123,7 +123,7 @@ module.exports = function(grunt) {
context: '/hideHeaders',
host: 'localhost',
port: 8081,
hideHeaders: ['x-hidden-header-1', 'x-hidden-header-2']
hideHeaders: ['x-hidden-header-1', 'X-HiDdEn-HeAdEr-2']
}
]
}
Expand Down
4 changes: 4 additions & 0 deletions lib/utils.js
Expand Up @@ -123,6 +123,10 @@ function removeHiddenHeaders(proxy) {
var hiddenHeaders = proxy.config.hideHeaders;

if(hiddenHeaders && hiddenHeaders.length > 0) {
hiddenHeaders = hiddenHeaders.map(function(header) {
return header.toLowerCase();
});

proxy.server.on('proxyRes', function(proxyRes) {
var headers = proxyRes.headers;
hiddenHeaders.forEach(function(header) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -34,7 +34,7 @@
"devDependencies": {
"grunt-contrib-jshint": "~0.1.1",
"grunt-contrib-clean": "~0.4.0",
"grunt-contrib-nodeunit": "~0.1.2",
"grunt-contrib-nodeunit": "~0.4.1",
"grunt": "~0.4.1",
"grunt-contrib-connect": "~0.5.0"
},
Expand Down
3 changes: 2 additions & 1 deletion test/hide_headers_test.js
Expand Up @@ -23,8 +23,9 @@ exports.connect_proxy = {
path: '/hideHeaders',
port: 9000
}, function(response) {

test.equal(response.headers['x-hidden-header-1'], undefined, 'hidden header should be hidden');
test.equal(response.headers['x-hidden-header-2'], undefined, 'hidden header should also be hidden');
test.equal(response.headers['x-hidden-header-2'], undefined, 'header hiding is case insensitive');
test.done();
}).end();
}
Expand Down

0 comments on commit b81a2a0

Please sign in to comment.