From 2d1c634bf448033e536cb487d92fba0e97ce2b9a Mon Sep 17 00:00:00 2001 From: Cisco Cervellera <16772290+ciscoski@users.noreply.github.com> Date: Sat, 21 Sep 2024 11:15:21 +0100 Subject: [PATCH] fix: Add hyphen to the allowed plugin names (#352) SDK like gcc-arm-none-eabi are well known with their dashes. This commits allow plugins to have name with dashes. --- internal/plugin.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/internal/plugin.go b/internal/plugin.go index e10ad4d9..4ef443ab 100644 --- a/internal/plugin.go +++ b/internal/plugin.go @@ -24,6 +24,8 @@ import ( "path/filepath" "regexp" + "strings" + "github.com/pterm/pterm" "github.com/version-fox/vfox/internal/cache" "github.com/version-fox/vfox/internal/env" @@ -31,7 +33,6 @@ import ( "github.com/version-fox/vfox/internal/luai" "github.com/version-fox/vfox/internal/util" lua "github.com/yuin/gopher-lua" - "strings" ) const ( @@ -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) }