From 7d18e7aa0d80fe8db8b610d39b971b7876e9e234 Mon Sep 17 00:00:00 2001 From: Fredrik Skogman Date: Mon, 20 May 2024 07:52:36 +0200 Subject: [PATCH] PR feedback. Juse more JS idiomatic code --- packages/attest/src/endpoints.ts | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/packages/attest/src/endpoints.ts b/packages/attest/src/endpoints.ts index 28b63ac7..9f6467de 100644 --- a/packages/attest/src/endpoints.ts +++ b/packages/attest/src/endpoints.ts @@ -42,15 +42,14 @@ export const signingEndpoints = (sigstore?: SigstoreInstance): Endpoints => { } function buildGitHubEndpoints(): Endpoints { - const serverURL = process.env.GITHUB_SERVER_URL ?? `https://github.com` - let url = serverURL.replace('https://', '') + const serverURL = process.env.GITHUB_SERVER_URL || 'https://github.com' + let host = new URL(serverURL).hostname - if (url === 'github.com') { - url = 'githubapp.com' + if (host === 'github.com') { + host = 'githubapp.com' } - const endpoints: Endpoints = { - fulcioURL: `https://fulcio.${url}`, - tsaServerURL: `https://timestamp.${url}` + return { + fulcioURL: `https://fulcio.${hostl}`, + tsaServerURL: `https://timestamp.${host}` } - return endpoints }