Skip to content

Commit

Permalink
fix: Add hyphen to the allowed plugin names (#352)
Browse files Browse the repository at this point in the history
SDK like gcc-arm-none-eabi are well known with their
dashes.
This commits allow plugins to have name with dashes.
  • Loading branch information
ciscoski authored Sep 21, 2024
1 parent dda9fc5 commit 2d1c634
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions internal/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,15 @@ import (
"path/filepath"
"regexp"

"strings"

"github.com/pterm/pterm"
"github.com/version-fox/vfox/internal/cache"
"github.com/version-fox/vfox/internal/env"
"github.com/version-fox/vfox/internal/logger"
"github.com/version-fox/vfox/internal/luai"
"github.com/version-fox/vfox/internal/util"
lua "github.com/yuin/gopher-lua"
"strings"
)

const (
Expand Down Expand Up @@ -622,7 +623,7 @@ func NewLuaPlugin(pluginDirPath string, manager *Manager) (*LuaPlugin, error) {

func isValidName(name string) bool {
// The regular expression means: start with a letter,
// followed by any number of letters, digits, or underscores.
re := regexp.MustCompile(`^[a-zA-Z][a-zA-Z0-9_]*$`)
// followed by any number of letters, digits, underscores, or hyphens.
re := regexp.MustCompile(`^[a-zA-Z][a-zA-Z0-9_\-]*$`)
return re.MatchString(name)
}

0 comments on commit 2d1c634

Please sign in to comment.