From 6d932e0f62c833f3d8aa01063d814871b8828f9a Mon Sep 17 00:00:00 2001 From: noamd-legit <74864790+noamd-legit@users.noreply.github.com> Date: Sun, 14 Apr 2024 11:36:11 -0400 Subject: [PATCH] fix: legitify action (#300) * fix extra args --- index.js | 9 ++++++++- internal/common/namespace/namespace.go | 10 +++++++--- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/index.js b/index.js index 0fb07e0f..cf9b254d 100644 --- a/index.js +++ b/index.js @@ -140,7 +140,14 @@ async function fetchLegitifyReleaseUrl(baseVersion) { function breakStringToParams(str) { const pattern = /(-{1,2}\S+)(?:\s+((?!\s*-).+?)(?=\s+-{1,2}|\s*$))?/g; - return str.match(pattern) + const matches = str.matchAll(pattern) + let args = [] + + for (const m of matches) { + args.push(m[1], m[2]) + } + + return args } function generateAnalyzeArgs(repo, owner) { diff --git a/internal/common/namespace/namespace.go b/internal/common/namespace/namespace.go index 3947169d..584892d6 100644 --- a/internal/common/namespace/namespace.go +++ b/internal/common/namespace/namespace.go @@ -1,6 +1,9 @@ package namespace -import "fmt" +import ( + "fmt" + "strings" +) type Namespace = string @@ -25,15 +28,16 @@ var All = []Namespace{ func ValidateNamespaces(namespace []Namespace) error { for _, ns := range namespace { found := false + trimmed := strings.Trim(ns, " ") for _, e := range All { - if e == ns { + if e == trimmed { found = true break } } if !found { - return fmt.Errorf("invalid namespace %s", ns) + return fmt.Errorf("invalid namespace %s", trimmed) } }