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

modify slug_generator to include . #2

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

DininduSenanayake
Copy link
Collaborator

@DininduSenanayake DininduSenanayake commented Aug 31, 2024

Previous implementation will not preserve dots in usernames. For example, "john.doe" would be converted to "john-doe".

To modify the function to accept usernames with dots, we need to update the NON_ALPHANUM_PATTERN and possibly adjust the OBJECT_PATTERN.

key changes made:

  1. Added dot (".") to LOWER_PLUS_HYPHEN array.
  2. Updated OBJECT_PATTERN and LABEL_PATTERN to include dot.
  3. Modified NON_ALPHANUM_PATTERN to allow dots: /[^a-z0-9\.]+/

didn't need to modify the extract_safe_name method itself because the changes to NON_ALPHANUM_PATTERN are sufficient to preserve dots. ( I think)

@DininduSenanayake
Copy link
Collaborator Author

Updated test-suite for

  • Dots are preserved in valid usernames.
  • Multiple dots are handled correctly.
  • Leading and trailing dots are removed.
  • Mixtures of dots and hyphens are preserved.
  • Long names with dots are truncated and hashed appropriately.
  • Slugs don't end with hyphens or dots

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.

1 participant