Skip to content

Commit

Permalink
fix(footer): api version extraction
Browse files Browse the repository at this point in the history
  • Loading branch information
aleksasiriski committed Jun 21, 2024
1 parent 146ae69 commit c1b5dc5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/lib/components/footer/main.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
Source code
</a>
<p class="text-sm text-neutral-600 dark:text-neutral-300 font-light">
UI ver: {uiVersion} | Agent ver: {apiVersion.replace(/;$/, '')}
UI ver: {uiVersion} | Agent ver: {apiVersion}
</p>
</div>
</footer>
15 changes: 14 additions & 1 deletion src/routes/+layout.js
Original file line number Diff line number Diff line change
@@ -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'
};
}

0 comments on commit c1b5dc5

Please sign in to comment.