Skip to content

Commit

Permalink
regex is slow
Browse files Browse the repository at this point in the history
  • Loading branch information
ajayk committed Jan 5, 2025
1 parent 94483fb commit 4c8ea86
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions pkg/build/pipeline.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import (
"os/signal"
"path"
"path/filepath"
"regexp"
"strconv"
"strings"

Expand Down Expand Up @@ -165,8 +164,13 @@ func validateWith(data map[string]string, inputs map[string]config.Input) (map[s
}

func matchValidShaChars(s string) bool {
match, _ := regexp.MatchString("^[a-fA-F0-9]+$", s)
return match
for i := 0; i < len(s); i++ {
c := s[i]
if !(c >= '0' && c <= '9') && !(c >= 'a' && c <= 'f') && !(c >= 'A' && c <= 'F') {
return false
}
}
return true
}

// Build a script to run as part of evalRun
Expand Down

0 comments on commit 4c8ea86

Please sign in to comment.