MCPcopy Create free account
hub / github.com/github/gh-aw / normalizeSanitizeSeparators

Function normalizeSanitizeSeparators

pkg/stringutil/sanitize.go:122–131  ·  view source on GitHub ↗

normalizeSanitizeSeparators converts common separators to hyphens and optionally converts underscores when they are not in the preserve list.

(result string, opts *SanitizeOptions)

Source from the content-addressed store, hash-verified

120// normalizeSanitizeSeparators converts common separators to hyphens and optionally
121// converts underscores when they are not in the preserve list.
122func normalizeSanitizeSeparators(result string, opts *SanitizeOptions) string {
123 result = strings.ReplaceAll(result, ":", "-")
124 result = strings.ReplaceAll(result, "\\", "-")
125 result = strings.ReplaceAll(result, "/", "-")
126 result = strings.ReplaceAll(result, " ", "-")
127 if !slices.Contains(opts.PreserveSpecialChars, '_') {
128 result = strings.ReplaceAll(result, "_", "-")
129 }
130 return result
131}
132
133// buildSanitizePreservePattern builds a regex character class of allowed characters.
134func buildSanitizePreservePattern(opts *SanitizeOptions) string {

Callers 1

SanitizeNameFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected