aboutsummaryrefslogtreecommitdiff
path: root/ref/name/sanitize.go
blob: f543de7ca1f7953eb30fe3b1ff29ee199067cf3b (about) (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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()
}