Skip to content

Commit

Permalink
Merge pull request #321 from hearchco/as/fix/version
Browse files Browse the repository at this point in the history
fix(footer): api version extraction
  • Loading branch information
aleksasiriski authored Jun 21, 2024
2 parents 8c6ca63 + c1b5dc5 commit 697b537
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 697b537

Please sign in to comment.