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

Improve slugify that isn't working with some cases #9

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

aleaforny
Copy link

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.

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, but I guess it depends on your system.

____________
**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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants