mirror of
https://github.com/crawlab-team/crawlab.git
synced 2026-01-22 17:31:03 +01:00
feat: add ToKebabCase utility function for string formatting
- Introduced a new function ToKebabCase in utils/string.go to convert strings to kebab-case format. - The function trims whitespace, converts to lowercase, and replaces spaces and underscores with hyphens, enhancing string manipulation capabilities in the codebase.
This commit is contained in:
@@ -21,3 +21,11 @@ func ToPascalCase(s string) string {
|
||||
s = strings.ReplaceAll(s, " ", "")
|
||||
return s
|
||||
}
|
||||
|
||||
func ToKebabCase(s string) string {
|
||||
s = strings.TrimSpace(s)
|
||||
s = strings.ToLower(s)
|
||||
s = strings.ReplaceAll(s, " ", "-")
|
||||
s = strings.ReplaceAll(s, "_", "-")
|
||||
return s
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user