From ed12aaeb2cb3d9c4cdb62d6922ee3f43dc8999d8 Mon Sep 17 00:00:00 2001 From: Sayamame-beans <61457993+Sayamame-beans@users.noreply.github.com> Date: Thu, 17 Aug 2023 00:55:09 +0900 Subject: [PATCH] fix(frontend): Possibility of exception in non-semver version format --- .../frontend/src/pages/settings/plugin.install.vue | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/frontend/src/pages/settings/plugin.install.vue b/packages/frontend/src/pages/settings/plugin.install.vue index 1fb8105c01..d848f8e21c 100644 --- a/packages/frontend/src/pages/settings/plugin.install.vue +++ b/packages/frontend/src/pages/settings/plugin.install.vue @@ -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 :(`,