Add safe slug generation func in package id

This commit is contained in:
Matt Baer
2018-10-15 17:41:41 -04:00
parent fcb3ad5c6b
commit 6c98a50085
2 changed files with 31 additions and 0 deletions
+12
View File
@@ -0,0 +1,12 @@
package id
import (
"fmt"
"github.com/writeas/nerds/store"
)
// GenSafeUniqueSlug generatees a reasonably unique random slug from the given
// original slug. It's "safe" because it uses 0-9 b-z excluding vowels.
func GenSafeUniqueSlug(slug string) string {
return fmt.Sprintf("%s-%s", slug, store.GenerateRandomString("0123456789bcdfghjklmnpqrstvwxyz", 4))
}