Slugify icon indicating copy to clipboard operation
Slugify copied to clipboard

Slug shortening

Open Zetanova opened this issue 7 months ago • 1 comments

This #151 only truncates the slug to size.

An option for shortening with a postfix is missing. The postfix could be a part of the full hash (1 byte)

This case should no produce the same slug when shorten to length 12: "The very long name liga" => the-very-long-name-liga => the-very-b2 (11 long) "The very long name liga (W)" => the-very-long-name-liga-w => the-very-d7 (11 long) "The very long name liga (M)" => the-very-long-name-liga-m => the-very-70 (11 long)

I am using it already, but to make an PR I would need a decision what hash to use my fav. murmur3 hash would require a dep. or a bit of code

CRC-8 should work fine in this case, the issue would be there that it has a lot of variants https://crccalc.com/?crc=the-very-long-name-liga-m&method=CRC-8&datatype=ascii&outtype=hex

Zetanova avatar Mar 26 '25 08:03 Zetanova