This repository has been archived on 2025-06-10. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
server/libfic/utils.go

12 lines
250 B
Go

package fic
import (
"regexp"
"strings"
)
// ToURLid converts the given string to a valid URLid.
func ToURLid(str string) string {
re := regexp.MustCompile("[^a-zA-Z0-9]+")
return strings.TrimSuffix(re.ReplaceAllLiteralString(str, "-"), "-")
}