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:
parent
dc1d5ce4f2
commit
98c1c101ee
@ -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([]);
|
||||
});
|
||||
|
@ -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[];
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user