MCPcopy Index your code
hub / github.com/devspace-sh/devspace / SafeConcatNameMax

Function SafeConcatNameMax

pkg/util/encoding/encoding.go:18–25  ·  view source on GitHub ↗
(name []string, max int)

Source from the content-addressed store, hash-verified

16}
17
18func SafeConcatNameMax(name []string, max int) string {
19 fullPath := strings.Join(name, "-")
20 if len(fullPath) > max {
21 digest := sha256.Sum256([]byte(fullPath))
22 return strings.ReplaceAll(fullPath[0:max-8]+"-"+hex.EncodeToString(digest[0:])[0:7], ".-", "-")
23 }
24 return fullPath
25}
26
27var convertRegEx1 = regexp.MustCompile(`[\@/\.\:\s]+`)
28var convertRegEx2 = regexp.MustCompile(`[^a-z0-9\-]+`)

Callers 2

SafeConcatNameFunction · 0.85
SafeConcatGenerateNameFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected