diff options
Diffstat (limited to 'internal/slug/slug.go')
| -rw-r--r-- | internal/slug/slug.go | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/internal/slug/slug.go b/internal/slug/slug.go index a3c99a4..197160c 100644 --- a/internal/slug/slug.go +++ b/internal/slug/slug.go @@ -27,6 +27,15 @@ var greek = strings.NewReplacer( // Make returns a slug for s; falls back to "untitled" when nothing usable remains. func Make(s string) string { + if s = Clean(s); s == "" { + return "untitled" + } + return s +} + +// Clean is Make without the fallback: "" when nothing usable remains, so a +// caller can reject the input (a tag) rather than name it "untitled". +func Clean(s string) string { if t, _, err := transform.String(stripMarks, s); err == nil { s = t } @@ -36,9 +45,6 @@ func Make(s string) string { if len(s) > 80 { s = strings.Trim(s[:80], "-") } - if s == "" { - return "untitled" - } return s } |
