Skip to content

Commit

Permalink
fix get auth header error (#374)
Browse files Browse the repository at this point in the history
Co-authored-by: Katie Dai <[email protected]>
  • Loading branch information
kdai7 and Katie Dai authored Nov 9, 2022
1 parent 513cf66 commit 44aeca5
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/git/github.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ module.exports = class Github extends Git {
}

getAuthHeaders(reqOpt) {
if (reqOpt.headers.Authorization && !reqOpt.headers.Authorization.includes('token')) {
if (reqOpt.headers && reqOpt.headers.Authorization && !reqOpt.headers.Authorization.includes('token')) {
reqOpt.headers = { ...reqOpt.headers, Authorization: 'token ' + reqOpt.headers.Authorization };
}
reqOpt.headers = { ...reqOpt.headers, 'User-Agent': this.owner };
Expand Down
2 changes: 1 addition & 1 deletion src/git/gitlab.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ module.exports = class Gitlab extends Git {
}

getAuthHeaders(reqOpt) {
if (reqOpt.headers.Authorization && !reqOpt.headers.Authorization.includes('Bearer')) {
if (reqOpt.headers && reqOpt.headers.Authorization && !reqOpt.headers.Authorization.includes('Bearer')) {
reqOpt.headers = { ...reqOpt.headers, Authorization: 'Bearer ' + reqOpt.headers.Authorization };
}
return reqOpt;
Expand Down

0 comments on commit 44aeca5

Please sign in to comment.