Skip to content

Commit

Permalink
Fixed truncation issue (#77)
Browse files Browse the repository at this point in the history
  • Loading branch information
Aym3nTN authored Oct 5, 2022
1 parent e79300e commit 1eab316
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion slug.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ func MakeLang(s string, lang string) (slug string) {
slug = strings.ToLower(slug)
}

if !EnableSmartTruncate {
if !EnableSmartTruncate && len(slug) >= MaxLength {
slug = slug[:MaxLength]
}

Expand Down
2 changes: 2 additions & 0 deletions slug_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,7 @@ func TestSlugMakeSmartTruncate(t *testing.T) {
{"Dobroslaw Zybort", 9, "dobroslaw", true},
{"Dobroslaw Zybort", 12, "dobroslaw", true},
{"Dobroslaw Zybort", 15, "dobroslaw", true},
{"Dobroslaw Zybort", 15, "dobroslaw-zybor", false},
{"Dobroslaw Zybort", 16, "dobroslaw-zybort", true},
{"Dobroslaw Zybort", 17, "dobroslaw-zybort", true},
{"Dobroslaw Zybort", 100, "dobroslaw-zybort", true},
Expand All @@ -312,6 +313,7 @@ func TestSlugMakeSmartTruncate(t *testing.T) {

{"DOBROSLAWZYBORT", 9, "dobroslaw", true},
{"DOBROSLAWZYBORT", 15, "dobroslawzybort", true},
{"DOBROSLAWZYBORT", 17, "dobroslawzybort", false},
{"DOBROSLAWZYBORT", 100, "dobroslawzybort", true},
{" Dobroslaw Zybort ?", 12, "dobroslaw", true},
{"Ala ma 6 kotów.", 10, "ala-ma-6", true},
Expand Down

0 comments on commit 1eab316

Please sign in to comment.