fix(frontend): Possibility of exception in non-semver version format

This commit is contained in:
Sayamame-beans 2023-08-17 00:55:09 +09:00 committed by GitHub
parent f5edf14f2d
commit ed12aaeb2c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -45,6 +45,14 @@ function installPlugin({ id, meta, src, token }) {
}));
}
function isSupportedAiScriptVersion(version: string): boolean {
try {
return (compareVersions(version, '0.12.0') >= 0);
} catch (err) {
return false;
}
}
async function install() {
if (code.value == null) return;
@ -55,7 +63,7 @@ async function install() {
text: 'No language version annotation found :(',
});
return;
} else if (compareVersions(lv, '0.12.0') < 0) {
} else if (!isSupportedAiScriptVersion(lv)) {
os.alert({
type: 'error',
text: `aiscript version '${lv}' is not supported :(`,