mirror of
https://github.com/nicotsx/ironmount.git
synced 2025-12-10 12:10:51 +01:00
chore: move to go folder
This commit is contained in:
18
go/internal/core/text-utils.go
Normal file
18
go/internal/core/text-utils.go
Normal file
@@ -0,0 +1,18 @@
|
||||
package core
|
||||
|
||||
import (
|
||||
"regexp"
|
||||
"strings"
|
||||
)
|
||||
|
||||
var nonAlnum = regexp.MustCompile(`[^a-z0-9_-]+`)
|
||||
|
||||
var hyphenRuns = regexp.MustCompile(`[-_]{2,}`)
|
||||
|
||||
func Slugify(input string) string {
|
||||
s := strings.ToLower(strings.TrimSpace(input))
|
||||
s = nonAlnum.ReplaceAllString(s, "-")
|
||||
s = hyphenRuns.ReplaceAllString(s, "-")
|
||||
s = strings.Trim(s, "-")
|
||||
return s
|
||||
}
|
||||
Reference in New Issue
Block a user