-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(workflows): ignore uuid strings when normalizing id strings (#8)
- Loading branch information
Yousuf Jawwad
committed
Sep 24, 2023
1 parent
26489b7
commit 7d1208c
Showing
2 changed files
with
37 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package workflows | ||
|
||
import ( | ||
"regexp" | ||
|
||
"github.com/gobeam/stringy" | ||
) | ||
|
||
var ( | ||
uuidrxstr = "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$" // taken from github.com/go-playground/validator | ||
) | ||
|
||
var ( | ||
uuidrx = regexp.MustCompile(uuidrxstr) | ||
) | ||
|
||
// format sanitizes a string and returns it. | ||
func format(s string) string { | ||
if uuidrx.MatchString(s) { | ||
return s | ||
} | ||
|
||
return stringy.New(s).SnakeCase("?", "", "#", "").ToLower() | ||
} |