From 44aeca5401da39b4d7ea3f7da70b6c54ed7e6c86 Mon Sep 17 00:00:00 2001 From: kdai7 <35241631+kdai7@users.noreply.github.com> Date: Wed, 9 Nov 2022 10:47:08 -0500 Subject: [PATCH] fix get auth header error (#374) Co-authored-by: Katie Dai --- src/git/github.js | 2 +- src/git/gitlab.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/git/github.js b/src/git/github.js index c68bd34c..12197a5a 100644 --- a/src/git/github.js +++ b/src/git/github.js @@ -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 }; diff --git a/src/git/gitlab.js b/src/git/gitlab.js index d8c85b12..a7e5a1f6 100644 --- a/src/git/gitlab.js +++ b/src/git/gitlab.js @@ -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;