gosimple / slug

URL-friendly slugify with multiple languages support.
Mozilla Public License 2.0
1.15k stars 108 forks source link

[bug] Issue when MaxLength is greater then string length and SmartTruncate is disabled #76

Closed Aym3nTN closed 2 years ago

Aym3nTN commented 2 years ago

When trying to truncate a string with a value greater than its size, we get the below error.

Example of failed test: {"DOBROSLAWZYBORT", 17, "dobroslawzybort", false}

--- FAIL: TestSlugMakeSmartTruncate (0.01s)
panic: runtime error: slice bounds out of range [:17] with length 15 [recovered]
    panic: runtime error: slice bounds out of range [:17] with length 15
matrixik commented 2 years ago

Thank you for fixing this bug. Merged and new version v1.13.1 released.