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' }; }