From c1b5dc5b391a9ad734dd12e04ec2a82d73897bac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aleksa=20Siri=C5=A1ki?= <31509435+aleksasiriski@users.noreply.github.com> Date: Fri, 21 Jun 2024 11:29:47 +0200 Subject: [PATCH] fix(footer): api version extraction --- src/lib/components/footer/main.svelte | 2 +- src/routes/+layout.js | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/lib/components/footer/main.svelte b/src/lib/components/footer/main.svelte index 31cd6572..de8a0f02 100644 --- a/src/lib/components/footer/main.svelte +++ b/src/lib/components/footer/main.svelte @@ -18,7 +18,7 @@ Source code

- UI ver: {uiVersion} | Agent ver: {apiVersion.replace(/;$/, '')} + UI ver: {uiVersion} | Agent ver: {apiVersion}

diff --git a/src/routes/+layout.js b/src/routes/+layout.js index 431aeaec..b75b7515 100644 --- a/src/routes/+layout.js +++ b/src/routes/+layout.js @@ -1,11 +1,24 @@ import { PUBLIC_UI_VERSION } from '$env/static/public'; import { fetchVersion } from '$lib/functions/api/fetchversion'; +/** + * @param {string} input + * @returns {string | null} + */ +function extractVersion(input) { + // Regular expression to match the version part + const versionRegex = /^v\d+\.\d+\.\d+/; + const match = input.match(versionRegex); + + // Return the matched version or null if not found + return match ? match[0] : null; +} + /** @type {import('./$types').LayoutLoad} */ export async function load({ fetch }) { const apiVersion = await fetchVersion(fetch); return { uiVersion: PUBLIC_UI_VERSION ?? 'dev', - apiVersion: apiVersion + apiVersion: extractVersion(apiVersion) ?? 'dev' }; }