MCPcopy
hub / github.com/cli/cli / camelToKebab

Function camelToKebab

pkg/search/query.go:347–359  ·  view source on GitHub ↗

CamelToKebab returns a copy of the string s that is converted from camel case form to '-' separated form.

(s string)

Source from the content-addressed store, hash-verified

345
346// CamelToKebab returns a copy of the string s that is converted from camel case form to '-' separated form.
347func camelToKebab(s string) string {
348 var output []rune
349 var segment []rune
350 for _, r := range s {
351 if !unicode.IsLower(r) && string(r) != "-" && !unicode.IsNumber(r) {
352 output = addSegment(output, segment)
353 segment = nil
354 }
355 segment = append(segment, unicode.ToLower(r))
356 }
357 output = addSegment(output, segment)
358 return string(output)
359}
360
361func addSegment(inrune, segment []rune) []rune {
362 if len(segment) == 0 {

Callers 2

MapMethod · 0.85
TestCamelToKebabFunction · 0.85

Calls 1

addSegmentFunction · 0.85

Tested by 1

TestCamelToKebabFunction · 0.68