mirror of
https://github.com/SigNoz/signoz.git
synced 2026-05-24 11:40:14 -05:00
`/status` was showing an upgrade-available banner even when the running build matched the latest release, because `checkVersionState` compared `currentVersion` (e.g. `v0.76.2`) against `latestVersion` (e.g. `0.76.2`) via raw string equality. Normalize both sides by stripping a leading `v`/`V` before comparing. Existing pre-release handling (`0.76.2-rc.1` → `0.76.2`) is preserved. Add a unit test covering exact match, either-side prefix mismatch, both prefixed, pre-release, and true mismatches. Fixes #7484
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
import { checkVersionState } from './app';
|
||||
|
||||
describe('checkVersionState', () => {
|
||||
it('returns true when both versions match exactly', () => {
|
||||
expect(checkVersionState('0.76.2', '0.76.2')).toBe(true);
|
||||
});
|
||||
|
||||
it('returns true when current version has a leading "v" and latest does not', () => {
|
||||
expect(checkVersionState('v0.76.2', '0.76.2')).toBe(true);
|
||||
});
|
||||
|
||||
it('returns true when latest version has a leading "v" and current does not', () => {
|
||||
expect(checkVersionState('0.76.2', 'v0.76.2')).toBe(true);
|
||||
});
|
||||
|
||||
it('returns true when both versions have a leading "v"', () => {
|
||||
expect(checkVersionState('v0.76.2', 'v0.76.2')).toBe(true);
|
||||
});
|
||||
|
||||
it('treats pre-release suffix on current as equivalent to the core version', () => {
|
||||
expect(checkVersionState('v0.76.2-rc.1', '0.76.2')).toBe(true);
|
||||
});
|
||||
|
||||
it('returns false for different versions regardless of prefix', () => {
|
||||
expect(checkVersionState('v0.76.1', '0.76.2')).toBe(false);
|
||||
expect(checkVersionState('0.76.1', 'v0.76.2')).toBe(false);
|
||||
});
|
||||
});
|
||||
@@ -16,12 +16,15 @@ export function extractDomain(email: string): string {
|
||||
return emailParts[1];
|
||||
}
|
||||
|
||||
const stripVersionPrefix = (version: string): string =>
|
||||
version?.replace(/^v/i, '') ?? '';
|
||||
|
||||
export const checkVersionState = (
|
||||
currentVersion: string,
|
||||
latestVersion: string,
|
||||
): boolean => {
|
||||
const versionCore = currentVersion?.split('-')[0];
|
||||
return versionCore === latestVersion;
|
||||
return stripVersionPrefix(versionCore) === stripVersionPrefix(latestVersion);
|
||||
};
|
||||
|
||||
// list of forbidden tags to remove in dompurify
|
||||
|
||||
Reference in New Issue
Block a user