2018-01-18 10:07:50 +00:00
|
|
|
package fic
|
|
|
|
|
|
|
|
import (
|
|
|
|
"regexp"
|
2018-01-22 23:59:40 +00:00
|
|
|
"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]+")
|
2018-01-22 23:59:40 +00:00
|
|
|
return strings.TrimSuffix(re.ReplaceAllLiteralString(str, "-"), "-")
|
2018-01-18 10:07:50 +00:00
|
|
|
}
|