blob: 5cdc83846da6f4befe3d7cfaad1505c656636517 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
package skate
import (
"fmt"
"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) {
fmt.Fprintf(&sb, "%c", c)
}
}
return strings.Join(strings.Fields(sb.String()), " ")
}
|