Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Slug length can be MaxLength+1 #72

Closed
Redlinkk opened this issue Aug 1, 2022 · 2 comments · Fixed by #74
Closed

Slug length can be MaxLength+1 #72

Redlinkk opened this issue Aug 1, 2022 · 2 comments · Fixed by #74
Labels

Comments

@Redlinkk
Copy link
Contributor

Redlinkk commented Aug 1, 2022

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.

@matrixik matrixik added the bug label Sep 27, 2022
matrixik added a commit that referenced this issue Sep 30, 2022
Fix #72

* Add more TestSlugMakeSmartTruncate cases

Co-authored-by: Romain Poirot <romain.poirot@gitguardian.com>
Co-authored-by: Dobrosław Żybort <matrixik@gmail.com>
@matrixik
Copy link
Member

@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.

@Aym3nTN
Copy link
Contributor

Aym3nTN commented Oct 5, 2022

I actually found another case I described here #76

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
3 participants