Skip to content

Commit

Permalink
fix: legitify action (#300)
Browse files Browse the repository at this point in the history
* fix extra args
  • Loading branch information
noamd-legit committed Apr 14, 2024
1 parent db0b2ab commit 6d932e0
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
9 changes: 8 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
10 changes: 7 additions & 3 deletions internal/common/namespace/namespace.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package namespace

import "fmt"
import (
"fmt"
"strings"
)

type Namespace = string

Expand All @@ -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)
}
}

Expand Down

0 comments on commit 6d932e0

Please sign in to comment.