Skip to content

Commit

Permalink
Fix the secret identifier format to honor the case configured
Browse files Browse the repository at this point in the history
  • Loading branch information
puthrayaharness committed Jul 17, 2024
1 parent f528be6 commit 7d9350b
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,32 @@ func TrimQuotes(input string) string {
return input
}

<<<<<<< Updated upstream
=======
func GenerateHarnessUIFormatWithHyphensIdentifier(name string) string {
pattern := regexp.MustCompile(`<\+([^>]+)>`)
matches := pattern.FindAllStringSubmatch(name, -1)
preservedSubstrings := make(map[string]string)
for _, match := range matches {
placeholder := match[1]
preservedKey := fmt.Sprintf("<+%s>", placeholder)
preservedSubstrings[preservedKey] = match[0]
name = strings.ReplaceAll(name, preservedKey, "PLACEHOLDER")
}

name = removeAccents(name)
name = stripStartingChars(name)
name = stripSpecialChars2(name)
name = strings.ReplaceAll(name, " ", "-")

for _, preservedValue := range preservedSubstrings {
name = strings.ReplaceAll(name, "PLACEHOLDER", preservedValue)
}

return name
}

>>>>>>> Stashed changes
func GenerateHarnessUIFormatIdentifier(name string) string {
pattern := regexp.MustCompile(`<\+([^>]+)>`)
matches := pattern.FindAllStringSubmatch(name, -1)
Expand Down Expand Up @@ -239,6 +265,10 @@ func stripStartingChars(s string) string {
return regexp.MustCompile("^[0-9-$]*").ReplaceAllString(s, "")
}

func stripSpecialChars2(s string) string {
return regexp.MustCompile("[^-0-9a-zA-Z_$ ]").ReplaceAllString(s, "")
}

func stripSpecialChars(s string) string {
return regexp.MustCompile("[^0-9a-zA-Z_$ ]").ReplaceAllString(s, "")
}
Expand Down

0 comments on commit 7d9350b

Please sign in to comment.