@globocom/backstage-functions-sandbox
Advanced tools
Comparing version 0.4.0 to 0.4.1
@@ -0,5 +1,25 @@ | ||
function filterHeaders(headers) { | ||
const { | ||
'sandbox-omit-headers': omitHeaders, | ||
} = headers; | ||
if (!omitHeaders) { | ||
return headers; | ||
} | ||
const filteredHeaders = Object.assign({}, headers); | ||
omitHeaders | ||
.split(',') | ||
.map(s => s.trim()) | ||
.forEach(x => delete filteredHeaders[x]); | ||
return filteredHeaders; | ||
} | ||
class Request { | ||
constructor({ method, headers, query, body }) { | ||
this.method = method; | ||
this.headers = headers; | ||
this.headers = filterHeaders(headers || {}); | ||
this.query = query; | ||
@@ -6,0 +26,0 @@ this.body = body; |
{ | ||
"name": "@globocom/backstage-functions-sandbox", | ||
"version": "0.4.0", | ||
"version": "0.4.1", | ||
"description": "Sandbox for Backstage functions", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -28,2 +28,23 @@ const expect = require('chai').expect; | ||
}); | ||
describe('when pass a `sandbox-omit-headers` header', () => { | ||
before(() => { | ||
externalRequest = { | ||
headers: { | ||
host: 'localhost:3000', | ||
accept: '*/*', | ||
authorization: 'xpto', | ||
'sandbox-omit-headers': 'authorization,host', | ||
}, | ||
}; | ||
}); | ||
it('should skip related headers', () => { | ||
const req = new Request(externalRequest); | ||
expect(Object.keys(req.headers)).to.be.eql([ | ||
'accept', | ||
'sandbox-omit-headers', | ||
]); | ||
}); | ||
}); | ||
}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
45590
1148
29