Fixed null-handling in game version comparers

This commit is contained in:
Kir_Antipov 2024-01-03 18:35:57 +00:00
parent 43b1ff503e
commit 940eefb550

View file

@ -31,10 +31,10 @@ export interface CurseForgeGameVersion {
* An equality comparer that compares two game version names ignoring the "-Snapshot" suffix.
*/
export const CURSEFORGE_GAME_VERSION_SNAPSHOT_NAME_COMPARER: EqualityComparer<string> = (a, b) => {
const aVersion = a.replace("-Snapshot", "");
const bVersion = b.replace("-Snapshot", "");
const aVersion = a?.replace("-Snapshot", "");
const bVersion = b?.replace("-Snapshot", "");
return aVersion && bVersion && aVersion === bVersion;
return aVersion === bVersion;
};
/**
@ -43,10 +43,10 @@ export const CURSEFORGE_GAME_VERSION_SNAPSHOT_NAME_COMPARER: EqualityComparer<st
* are the same.
*/
export const CURSEFORGE_GAME_VERSION_PLUGIN_NAME_COMPARER: EqualityComparer<string> = (a, b) => {
const aVersion = a.match(/\d+\.\d+/)?.[0];
const bVersion = b.match(/\d+\.\d+/)?.[0];
const aVersion = a?.match(/\d+\.\d+/)?.[0];
const bVersion = b?.match(/\d+\.\d+/)?.[0];
return aVersion && bVersion && aVersion === bVersion;
return aVersion === bVersion;
};
/**