From 6c718820a4160c3117c2ecb47628e6aea79bac2f Mon Sep 17 00:00:00 2001 From: ShareVB Date: Sun, 22 Sep 2024 19:27:06 +0200 Subject: [PATCH] fix: better ui to select file or paste content --- .../certificate-key-parser.vue | 44 +++++++++++++------ 1 file changed, 30 insertions(+), 14 deletions(-) diff --git a/src/tools/certificate-key-parser/certificate-key-parser.vue b/src/tools/certificate-key-parser/certificate-key-parser.vue index b86b4bf1..b108de52 100644 --- a/src/tools/certificate-key-parser/certificate-key-parser.vue +++ b/src/tools/certificate-key-parser/certificate-key-parser.vue @@ -8,6 +8,7 @@ import { useDownloadFileFromBase64 } from '@/composable/downloadBase64'; const inputKeyOrCertificate = ref(''); const passphrase = ref(''); const fileInput = ref() as Ref; +const inputType = ref<'file' | 'content'>('file'); async function onUpload(file: File) { if (file) { @@ -37,11 +38,15 @@ function downloadX509DERFile() { } const parsedSections = computedAsync(async () => { - const inputKeyOrCertificateValue - = inputKeyOrCertificate.value !== '' - ? inputKeyOrCertificate.value - : fileInput.value; - + const inputContent = inputKeyOrCertificate.value; + const file = fileInput.value; + let inputKeyOrCertificateValue: string | Buffer = ''; + if (inputType.value === 'file' && file) { + inputKeyOrCertificateValue = file; + } + else if (inputType.value === 'content' && inputContent) { + inputKeyOrCertificateValue = inputContent; + } const { values, certificateX509DER: certPEM } = await getKeyOrCertificateInfosAsync(inputKeyOrCertificateValue, passphrase.value); certificateX509DER.value = certPEM || ''; return values; @@ -51,16 +56,27 @@ const parsedSections = computedAsync(async () => {