Fix description checking

This commit is contained in:
Him188 2020-09-12 20:38:06 +08:00
parent 3b9414dc50
commit 9b3e96e3d3
2 changed files with 4 additions and 4 deletions

View File

@ -115,7 +115,7 @@ public interface PluginDescription {
*
* @see PluginDescription.id
*/
public val ID_REGEX: Regex = Regex("""([a-zA-Z]+[a-zA-Z0-9]*)\.([a-zA-Z]+[a-zA-Z0-9]*)""")
public val ID_REGEX: Regex = Regex("""([a-zA-Z]+(?:\.[a-zA-Z0-9]+)*)\.([a-zA-Z]+(?:-[a-zA-Z0-9]+)*)""")
/**
* [PluginDescription.id] [PluginDescription.name] 中禁止用的完全匹配名称列表.
@ -137,7 +137,7 @@ public interface PluginDescription {
checkDependencies(instance.id, instance.dependencies)
}.getOrElse {
throw IllegalPluginDescriptionException(
"Illegal description. Plugin ${instance.name} (${instance.id})",
"Illegal PluginDescription. Plugin ${instance.name} (${instance.id})",
it
)
}
@ -173,7 +173,7 @@ public interface PluginDescription {
public fun checkPluginName(name: String) {
if (name.isBlank()) throw IllegalPluginDescriptionException("Plugin name cannot be blank")
val lowercaseName = name.toLowerCase()
FORBIDDEN_ID_NAMES.firstOrNull { it in lowercaseName }?.let { illegal ->
FORBIDDEN_ID_NAMES.firstOrNull { it == lowercaseName }?.let { illegal ->
throw IllegalPluginDescriptionException("Plugin name is illegal: '$illegal'.")
}
}

View File

@ -9,7 +9,7 @@
object Versions {
const val core = "1.2.3"
const val console = "1.0-M4-dev-8"
const val console = "1.0-M4-dev-10"
const val consoleGraphical = "0.0.7"
const val consoleTerminal = "0.1.0"
const val consolePure = console