diff options
| author | 2026-03-07 15:08:14 +0800 | |
|---|---|---|
| committer | 2026-03-07 15:56:39 +0800 | |
| commit | 9d08dc994d51298e2d8e75d8ed4ee477312ec53a (patch) | |
| tree | 28c2a53174dd319fbd330132d446ef9ead8cb7ee /ref/refname/sanitize.go | |
| parent | refstore: Remove Shorten for now (diff) | |
| signature | No signature | |
ref/refname: Add refname validation
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() +} |
