diff --git a/go.mod b/go.mod index b79ad52..7022959 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.22 require ( github.com/google/go-github/v43 v43.0.0 - github.com/gosimple/slug v1.14.0 + github.com/gosimple/slug v1.15.0 golang.org/x/oauth2 v0.21.0 ) diff --git a/go.sum b/go.sum index f9b377f..447374d 100644 --- a/go.sum +++ b/go.sum @@ -5,8 +5,8 @@ github.com/google/go-github/v43 v43.0.0 h1:y+GL7LIsAIF2NZlJ46ZoC/D1W1ivZasT0lnWH github.com/google/go-github/v43 v43.0.0/go.mod h1:ZkTvvmCXBvsfPpTHXnH/d2hP9Y0cTbvN9kr5xqyXOIc= github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8= github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU= -github.com/gosimple/slug v1.14.0 h1:RtTL/71mJNDfpUbCOmnf/XFkzKRtD6wL6Uy+3akm4Es= -github.com/gosimple/slug v1.14.0/go.mod h1:UiRaFH+GEilHstLUmcBgWcI42viBN7mAb818JrYOeFQ= +github.com/gosimple/slug v1.15.0 h1:wRZHsRrRcs6b0XnxMUBM6WK1U1Vg5B0R7VkIf1Xzobo= +github.com/gosimple/slug v1.15.0/go.mod h1:UiRaFH+GEilHstLUmcBgWcI42viBN7mAb818JrYOeFQ= github.com/gosimple/unidecode v1.0.1 h1:hZzFTMMqSswvf0LBJZCZgThIZrpDHFXux9KeGmn6T/o= github.com/gosimple/unidecode v1.0.1/go.mod h1:CP0Cr1Y1kogOtx0bJblKzsVWrqYaqfNOnHzpgWw4Awc= golang.org/x/crypto v0.24.0 h1:mnl8DM0o513X8fdIkmyFE/5hTYxbwYOjDS/+rK6qpRI= diff --git a/vendor/github.com/gosimple/slug/slug.go b/vendor/github.com/gosimple/slug/slug.go index 7d9c13a..b4ed7cd 100644 --- a/vendor/github.com/gosimple/slug/slug.go +++ b/vendor/github.com/gosimple/slug/slug.go @@ -38,6 +38,14 @@ var ( // Default is true. Lowercase = true + // DisableMultipleDashTrim defines if multiple dashes should be preserved. + // Default is false (multiple dashes will be replaced with single dash). + DisableMultipleDashTrim = false + + // DisableEndsTrim defines if the slug should keep leading and trailing + // dashes and underscores. Default is false (trim enabled). + DisableEndsTrim = false + // Append timestamp to the end in order to make slug unique // Default is false AppendTimestamp = false @@ -126,8 +134,12 @@ func MakeLang(s string, lang string) (slug string) { // Process all remaining symbols slug = regexpNonAuthorizedChars.ReplaceAllString(slug, "-") - slug = regexpMultipleDashes.ReplaceAllString(slug, "-") - slug = strings.Trim(slug, "-_") + if !DisableMultipleDashTrim { + slug = regexpMultipleDashes.ReplaceAllString(slug, "-") + } + if !DisableEndsTrim { + slug = strings.Trim(slug, "-_") + } if MaxLength > 0 && EnableSmartTruncate { slug = smartTruncate(slug) @@ -145,7 +157,7 @@ func MakeLang(s string, lang string) (slug string) { // order. Many passes, on one substitution another one could apply. func Substitute(s string, sub map[string]string) (buf string) { buf = s - var keys []string + keys := make([]string, 0, len(sub)) for k := range sub { keys = append(keys, k) } diff --git a/vendor/modules.txt b/vendor/modules.txt index b65f4ff..6562ed5 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -4,7 +4,7 @@ github.com/google/go-github/v43/github # github.com/google/go-querystring v1.1.0 ## explicit; go 1.10 github.com/google/go-querystring/query -# github.com/gosimple/slug v1.14.0 +# github.com/gosimple/slug v1.15.0 ## explicit; go 1.11 github.com/gosimple/slug # github.com/gosimple/unidecode v1.0.1