From 88aa2720fe270b3a080db9dbf39c5683981a46e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roger=20Bj=C3=B8rnstad?= Date: Mon, 10 Feb 2025 13:26:36 +0100 Subject: [PATCH] fix: validate commit SHA before displaying link in WorkloadDeploy component --- src/lib/components/WorkloadDeploy.svelte | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/src/lib/components/WorkloadDeploy.svelte b/src/lib/components/WorkloadDeploy.svelte index aa4f1178..0624583f 100644 --- a/src/lib/components/WorkloadDeploy.svelte +++ b/src/lib/components/WorkloadDeploy.svelte @@ -32,14 +32,13 @@ ) ); - //let workloadName = $derived($data.name); - //let workloadType = $derived($data.__typename === 'Application' ? 'app' : 'job'); - let deploymentInfo = $derived( $data.deployments.nodes.length > 0 ? $data.deployments.nodes[0] : null ); - //const githubOrganization = get(page).data.githubOrganization; + function isValidSha(sha: string): boolean { + return /^[0-9a-f]{40}$/i.test(sha); + }
@@ -54,15 +53,13 @@
Github action
{/if} - - + {#if deploymentInfo?.commitSha && isValidSha(deploymentInfo?.commitSha)} +
+ Commit {deploymentInfo?.commitSha.slice(0, 7)} +
+ {/if} {:else} No deployments {/if}