Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Add hyphen to the allowed plugin names #352

Merged
merged 1 commit into from
Sep 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
}