diff options
Diffstat (limited to 'ref/refname/sanitize.go')
| -rw-r--r-- | ref/refname/sanitize.go | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/ref/refname/sanitize.go b/ref/refname/sanitize.go new file mode 100644 index 00000000..f543de7c --- /dev/null +++ b/ref/refname/sanitize.go @@ -0,0 +1,19 @@ +package refname + +import ( + "fmt" + "strings" +) + +// SanitizeComponent mutates component until it satisfies +// sanitize_refname_component. +func SanitizeComponent(component string) string { + var builder strings.Builder + + err := checkOrSanitizeRefname(component, refnameAllowOneLevel, &builder) + if err != nil { + panic(fmt.Sprintf("ref: sanitize component %q: %v", component, err)) + } + + return builder.String() +} |
