MCPcopy Create free account
hub / github.com/algolia/cli / ToKebabCase

Function ToKebabCase

pkg/utils/utils.go:59–67  ·  view source on GitHub ↗

ToKebabCase converts a string to kebab case

(str string)

Source from the content-addressed store, hash-verified

57
58// ToKebabCase converts a string to kebab case
59func ToKebabCase(str string) string {
60 matchFirstCap := regexp.MustCompile("(.)([A-Z][a-z]+)")
61 matchAllCap := regexp.MustCompile("([a-z0-9])([A-Z])")
62
63 snake := matchFirstCap.ReplaceAllString(str, "${1}-${2}")
64 snake = matchAllCap.ReplaceAllString(snake, "${1}-${2}")
65
66 return strings.ToLower(snake)
67}
68
69// Convert comma separated string values to slice
70func StringToSlice(str string) []string {

Callers 1

TestToKebabCaseFunction · 0.85

Calls

no outgoing calls

Tested by 1

TestToKebabCaseFunction · 0.68