Skip to content

Commit

Permalink
fix(frontend): Possibility of exception in non-semver version format
Browse files Browse the repository at this point in the history
  • Loading branch information
Sayamame-beans authored Aug 16, 2023
1 parent f5edf14 commit ed12aae
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion packages/frontend/src/pages/settings/plugin.install.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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 :(`,
Expand Down

0 comments on commit ed12aae

Please sign in to comment.