From 115a5ce2f0169ce285d8d84642d922c9bfb5e3e1 Mon Sep 17 00:00:00 2001 From: Yeuoly Date: Thu, 7 Nov 2024 16:15:03 +0800 Subject: [PATCH] rules: strict using lower cases --- cmd/commandline/init/profile.go | 3 +++ internal/types/entities/plugin_entities/plugin_declaration.go | 1 + 2 files changed, 4 insertions(+) diff --git a/cmd/commandline/init/profile.go b/cmd/commandline/init/profile.go index eee867c..e2766ea 100644 --- a/cmd/commandline/init/profile.go +++ b/cmd/commandline/init/profile.go @@ -64,6 +64,9 @@ func (p *profile) checkRule() bool { } else if p.cursor == 0 && !plugin_entities.PluginNameRegex.MatchString(p.inputs[p.cursor].Value()) { p.warning = "Plugin name must be 1-128 characters long, and can only contain letters, numbers, dashes and underscores" return false + } else if p.cursor == 1 && !plugin_entities.AuthorRegex.MatchString(p.inputs[p.cursor].Value()) { + p.warning = "Author name must be 1-64 characters long, and can only contain letters, numbers, dashes and underscores" + return false } else { p.warning = "" } diff --git a/internal/types/entities/plugin_entities/plugin_declaration.go b/internal/types/entities/plugin_entities/plugin_declaration.go index e7efde7..0975125 100644 --- a/internal/types/entities/plugin_entities/plugin_declaration.go +++ b/internal/types/entities/plugin_entities/plugin_declaration.go @@ -261,6 +261,7 @@ func (p *PluginDeclaration) MarshalJSON() ([]byte, error) { var ( PluginNameRegex = regexp.MustCompile(`^[a-z0-9_-]{1,128}$`) + AuthorRegex = regexp.MustCompile(`^[a-z0-9_-]{1,64}$`) PluginDeclarationVersionRegex = regexp.MustCompile(`^\d{1,4}(\.\d{1,4}){1,3}(-\w{1,16})?$`) )