Skip to content

Commit

Permalink
fix: amend accept header for github apps, keep custom accept headers …
Browse files Browse the repository at this point in the history
…intact
  • Loading branch information
gr2m committed May 14, 2018
1 parent c614739 commit 09e3c46
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/plugins/authentication/before-request.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
module.exports = authenticationBeforeRequest

const btoa = require('btoa-lite')
const uniq = require('lodash/uniq')

function authenticationBeforeRequest (state, options) {
if (!state.auth.type) {
Expand All @@ -26,7 +27,9 @@ function authenticationBeforeRequest (state, options) {

if (state.auth.type === 'app') {
options.headers['authorization'] = `Bearer ${state.auth.token}`
options.headers['accept'] = 'application/vnd.github.machine-man-preview+json'
const acceptHeaders = options.headers['accept'].split(',')
.concat('application/vnd.github.machine-man-preview+json')
options.headers['accept'] = uniq(acceptHeaders).filter(Boolean).join(',')
return
}

Expand Down

0 comments on commit 09e3c46

Please sign in to comment.