server/libfic/utils.go

13 lines
250 B
Go
Raw Normal View History

2018-01-18 10:07:50 +00:00
package fic
import (
"regexp"
"strings"
2018-01-18 10:07:50 +00:00
)
2018-03-09 18:07:08 +00:00
// ToURLid converts the given string to a valid URLid.
2018-01-18 10:07:50 +00:00
func ToURLid(str string) string {
re := regexp.MustCompile("[^a-zA-Z0-9]+")
return strings.TrimSuffix(re.ReplaceAllLiteralString(str, "-"), "-")
2018-01-18 10:07:50 +00:00
}