mirror of
https://github.com/tmedwards/tweego.git
synced 2025-07-05 06:00:26 -04:00
[Update] Update slugify()
again.
* Reduced the regexp by switching fully to ranges. * Switched replacement character to underscore. * Dropped lowercasing.
This commit is contained in:
parent
2d91f1ce96
commit
ea69d81375
1 changed files with 2 additions and 2 deletions
4
util.go
4
util.go
|
@ -94,9 +94,9 @@ func slugify(original string) string {
|
|||
// less-than, equals, greater-than, question, at, left bracket, backslash, right
|
||||
// bracket, caret, backquote/grave, left brace, pipe/vertical-bar, right brace, tilde,
|
||||
// delete, C1 controls.
|
||||
invalidRe := regexp.MustCompile(`[\x00-\x20!"#$%&'()*+,\-./:;<=>?@[\\\]^\x60{|}~\x7f-\x9f]+`)
|
||||
illegalRe := regexp.MustCompile(`[\x00-\x20!-/:-@[-^\x60{-\x9f]+`)
|
||||
|
||||
return strings.ToLower(invalidRe.ReplaceAllLiteralString(original, "-"))
|
||||
return illegalRe.ReplaceAllLiteralString(original, "_")
|
||||
}
|
||||
|
||||
func stringSliceContains(haystack []string, needle string) bool {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue