gosimple / slug

URL-friendly slugify with multiple languages support.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Slug length can be MaxLength+1

Redlinkk opened this issue · comments

When using the truncate function, the slug can be longer than MaxLength on specific conditions. See this example:

  • original string (of length 11): "abcde-fghij"
  • MaxLength: 10
  • expected string: "abcde"
  • output string: "abcde-fghij"

Current function fails on this edge case because the last word doesn't end with a "-" during the max length test here so the - 1 is wrongfully applied.

@Redlinkk Thank you for catching this, I added more tests, fixed one more problem and merged it. Now it's part of v1.13.0 release.

I actually found another case I described here #76