tailcfg: use strings.CutPrefix for CheckTag; add test
Updates #cleanup Signed-off-by: Andrew Dunham <andrew@du.nham.ca> Change-Id: I42eddc7547a6dd50c4d5b2a9fc88a19aac9767aa
This commit is contained in:
+3
-2
@@ -609,10 +609,11 @@ func isAlpha(b byte) bool {
|
||||
//
|
||||
// We might relax these rules later.
|
||||
func CheckTag(tag string) error {
|
||||
if !strings.HasPrefix(tag, "tag:") {
|
||||
var ok bool
|
||||
tag, ok = strings.CutPrefix(tag, "tag:")
|
||||
if !ok {
|
||||
return errors.New("tags must start with 'tag:'")
|
||||
}
|
||||
tag = tag[4:]
|
||||
if tag == "" {
|
||||
return errors.New("tag names must not be empty")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user