From ea69d813753a2a7439624650c31771416cfc1a13 Mon Sep 17 00:00:00 2001 From: "Thomas M. Edwards" Date: Tue, 25 Feb 2020 00:56:36 -0600 Subject: [PATCH] [Update] Update `slugify()` again. * Reduced the regexp by switching fully to ranges. * Switched replacement character to underscore. * Dropped lowercasing. --- util.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/util.go b/util.go index 310ec2e..4bf56a5 100644 --- a/util.go +++ b/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 {