Unverified Commit 16ef37f8 authored by Peter Murray's avatar Peter Murray Committed by GitHub
Browse files

HTTP errors when the token is undefined (#556)

* Fixing issues with the handling of the token and avoiding error on when the token is undefined

* chore: rebuild action

---------

Co-authored-by: default avatarIvan Zosimov <[email protected]>
parent a2374547
Loading
Loading
Loading
Loading
+3 −1
Changes for dist/cleanup/index.js: 3 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -87931,9 +87931,11 @@ function getGitHubHttpHeaders() {
    const token = core.getInput('token');
    const auth = !token ? undefined : `token ${token}`;
    const headers = {
        authorization: auth,
        accept: 'application/vnd.github.VERSION.raw'
    };
    if (auth) {
        headers.authorization = auth;
    }
    return headers;
}
exports.getGitHubHttpHeaders = getGitHubHttpHeaders;
+3 −1
Changes for dist/setup/index.js: 3 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -125282,9 +125282,11 @@ function getGitHubHttpHeaders() {
    const token = core.getInput('token');
    const auth = !token ? undefined : `token ${token}`;
    const headers = {
        authorization: auth,
        accept: 'application/vnd.github.VERSION.raw'
    };
    if (auth) {
        headers.authorization = auth;
    }
    return headers;
}
exports.getGitHubHttpHeaders = getGitHubHttpHeaders;
+5 −1
Changes for src/util.ts: 5 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -166,9 +166,13 @@ export function convertVersionToSemver(version: number[] | string) {
export function getGitHubHttpHeaders(): OutgoingHttpHeaders {
  const token = core.getInput('token');
  const auth = !token ? undefined : `token ${token}`;

  const headers: OutgoingHttpHeaders = {
    authorization: auth,
    accept: 'application/vnd.github.VERSION.raw'
  };

  if (auth) {
    headers.authorization = auth;
  }
  return headers;
}