From 367b17ad7f0ff8cc68d07346089441cbb13f7897 Mon Sep 17 00:00:00 2001 From: Him188 Date: Sun, 23 Aug 2020 02:31:27 +0800 Subject: [PATCH] Ignore 'v' and 'V' prefixes in plugin versions --- .../console/internal/data/SemverAsStringSerializer.kt | 8 ++++++-- .../kotlin/net/mamoe/mirai/console/plugin/description.kt | 3 +-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/internal/data/SemverAsStringSerializer.kt b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/internal/data/SemverAsStringSerializer.kt index f319a7a0a..644819966 100644 --- a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/internal/data/SemverAsStringSerializer.kt +++ b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/internal/data/SemverAsStringSerializer.kt @@ -17,11 +17,15 @@ import kotlinx.serialization.builtins.serializer @Serializer(forClass = Semver::class) internal object SemverAsStringSerializerLoose : KSerializer by String.serializer().map( serializer = { it.toString() }, - deserializer = { Semver(it, Semver.SemverType.LOOSE) } + deserializer = { + Semver(it.removePrefix("v").removePrefix("V"), Semver.SemverType.LOOSE) + } ) @Serializer(forClass = Semver::class) internal object SemverAsStringSerializerIvy : KSerializer by String.serializer().map( serializer = { it.toString() }, - deserializer = { Semver(it, Semver.SemverType.IVY) } + deserializer = { + Semver(it.removePrefix("v").removePrefix("V"), Semver.SemverType.IVY) + } ) \ No newline at end of file diff --git a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/plugin/description.kt b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/plugin/description.kt index 7389c1bcc..bb7e42d10 100644 --- a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/plugin/description.kt +++ b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/plugin/description.kt @@ -14,7 +14,6 @@ import kotlinx.serialization.KSerializer import kotlinx.serialization.Serializable import kotlinx.serialization.builtins.serializer import kotlinx.serialization.encodeToString -import net.mamoe.mirai.console.internal.data.SemverAsStringSerializerIvy import net.mamoe.mirai.console.internal.data.map import net.mamoe.yamlkt.Yaml import net.mamoe.yamlkt.YamlDynamicSerializer @@ -49,7 +48,7 @@ public interface PluginDescription { * * 语法参考: ([语义化版本 2.0.0](https://semver.org/lang/zh-CN/)) * - * @see Semver 语义化版本 + * @see Semver 语义化版本. 允许 [宽松][Semver.SemverType.LOOSE] 类型版本. */ public val version: Semver