slugify
slugify copied to clipboard
Improve slugify that isn't working with some cases
Let's take this example string : This IS- a C/O/MPLEX STRING - look@THAT
According to regular slugifiers (https://slugify.online/), this string slugified should be this-is-a-complex-string-lookthat
However, with default slugify(), it will returns a strange string with additional dashes, thus, not very slugify-friendly.
Here the output : this-is--a-complex-string---lookatthat
With the codes changes, slugify() returns the expected string (I just also modified the remplacements.dart
files to my convenience in order to prevent the '@' to become 'at', but I guess it depends on your system and your expectations)
Explanations
- Somehow, the
_dupeSpaceRegExp
has been fixed. - Then, the substition between the two regexes
_dupeSpaceRegExp
and_punctuationRegExp
were to fix too; I changed the order. Now works as expected.