Skip to content

Allow single char version slugs. #1407

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 1 commit into from
Jul 6, 2015
Merged

Conversation

gregmuellegger
Copy link
Contributor

The version slug regex was previously not allowing single char slugs. This PR fixes that and is adding appropriate tests.

Closes #1405.

@@ -30,7 +30,7 @@
# +? -- allow multiple of those, but be not greedy about the matching
# (?: ... ) -- wrap everything so that the pattern cannot escape when used in
# regexes.
VERSION_SLUG_REGEX = '(?:[a-z0-9][-._a-z0-9]+?)'
VERSION_SLUG_REGEX = '(?:[a-z0-9][-._a-z0-9]*?)'
Copy link
Contributor

Choose a reason for hiding this comment

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

I believe the final ? is not required here. * should catch none/any number of instances of allowed characters.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My initial intend for adding the "non-greedy" matcher was that the regex does not leak into some other bits of a URL regex when it is embedded into one. But, yeah, I think it won't make any difference in real use. Shall I remove it?

Copy link
Contributor

Choose a reason for hiding this comment

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

This makes sense, I figured there were some other cases to consider here. Should be fine leaving it

@gregmuellegger gregmuellegger force-pushed the allow-single-char-version-slugs branch from 212afb0 to e557a20 Compare July 6, 2015 11:37
@ericholscher
Copy link
Member

Seems like an edge case (in fact, it could only happen 26 times :) -- Perhaps we should set slugging rules, and require 3+ chars? At this size names/slugs are meaningless -- We've also run into issues in the past with UTF8 chars getting slugified poorly (eg. chinese chars will slug down to nothing). That might be another odd edge case that this code will hit.

@agjohnson
Copy link
Contributor

Opened #1410 to address UTF8 encoding on slugging. This looks good otherwise

agjohnson added a commit that referenced this pull request Jul 6, 2015
@agjohnson agjohnson merged commit afe4347 into master Jul 6, 2015
@gregmuellegger gregmuellegger deleted the allow-single-char-version-slugs branch August 3, 2015 13:57
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.

Migration failing on version slugs
3 participants