1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-02-23 00:22:19 +01:00

fix: handle sdk versions with nulls (#6558)

This commit is contained in:
Mateusz Kwasniewski 2024-03-14 15:47:34 +01:00 committed by GitHub
parent dc1d5ce4f2
commit 98c1c101ee
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 5 additions and 4 deletions

View File

@ -52,7 +52,7 @@ describe('findOutdatedSDKs', () => {
});
it('should ignore invalid SDK versions', () => {
const sdkVersions = ['unleash-client-node', '1.2.3'];
const sdkVersions = ['unleash-client-node', '1.2.3', null];
const result = findOutdatedSDKs(sdkVersions);
expect(result).toEqual([]);
});

View File

@ -14,7 +14,8 @@ const config: SDKConfig = {
'unleash-client-php': '2.3.0',
};
export const isOutdatedSdk = (sdkVersion: string) => {
export const isOutdatedSdk = (sdkVersion: string | null) => {
if (sdkVersion == null) return false;
const result = sdkVersion.split(':');
if (result.length !== 2) return false;
const [sdkName, version] = result;
@ -24,8 +25,8 @@ export const isOutdatedSdk = (sdkVersion: string) => {
return false;
};
export function findOutdatedSDKs(sdkVersions: string[]): string[] {
export function findOutdatedSDKs(sdkVersions: (string | null)[]): string[] {
const uniqueSdkVersions = Array.from(new Set(sdkVersions));
return uniqueSdkVersions.filter(isOutdatedSdk);
return uniqueSdkVersions.filter(isOutdatedSdk) as string[];
}