aboutsummaryrefslogtreecommitdiffstats
path: root/skate/slugify.go
blob: d8174855cd6f7d9c60b9c758823b8e6b05fbb53a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
package skate

import (
	"strings"
)

// slugifyString is a basic string slugifier.
func slugifyString(s string) string {
	var sb strings.Builder
	for _, c := range strings.TrimSpace(strings.ToLower(s)) {
		if (c > 96 && c < 123) || (c > 47 && c < 58) || (c == 32) || (c == 9) || (c == 10) {
			_, _ = sb.WriteRune(c)
		}
	}
	return strings.Join(strings.Fields(sb.String()), " ")
}