Skip to content

Fix slug generation for uppercase branch names #1396

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

Merged
merged 6 commits into from
Jul 6, 2015

Conversation

gregmuellegger
Copy link
Contributor

There is another issue with slugs that was raised in #1176. The current implementation turns uppercase letters into dashes so that SomeChar-charclass as branch name results in -ome-har-charclass as slug. However our regex in the URLs don't allow leading dashes.

This PR changes the algorithm to strip punctuation from the generated slug. It includes a migration to fix the currently broken slugs. I tested locally that pypy's version page works after applying it.

slug_length = len(slugified)

if not slugified:
return self.fallback_slug
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd also be +1 on replacing these blocks with regex comparisons/substitutions. These two blocks could be a single regex substitution, with a check against the final matches for empty/invalid slug.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea, that is addressed with the latest push. I've not used regex.sub before that's why I didn't think about it. It reduced the code quite a bit. Thanks for the suggestion!

@agjohnson
Copy link
Contributor

Excellent, looks good

agjohnson added a commit that referenced this pull request Jul 6, 2015
Fix slug generation for uppercase branch names
@agjohnson agjohnson merged commit c537b05 into master Jul 6, 2015
@agjohnson agjohnson deleted the fix-slug-generation-for-uppercase branch July 6, 2015 05:30
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