-
Notifications
You must be signed in to change notification settings - Fork 101
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
Fix ParseTolerant when zeros are continuous #56
Conversation
1 similar comment
@blang How about it? |
upvote merging, got hit by the same issue... |
@@ -243,7 +243,11 @@ func ParseTolerant(s string) (Version, error) { | |||
// Remove leading zeros. | |||
for i, p := range parts { | |||
if len(p) > 1 { | |||
parts[i] = strings.TrimPrefix(p, "0") | |||
p = strings.TrimLeft(p, "0") | |||
if len(p) == 0 || !strings.ContainsAny(p[0:1], "0123456789") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
might compare to empty string and drop 0
such that
if p == "" || !strings.ContainsAny(p[:1], "123456789) {
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Thanks for your contribution and long wait! |
It fixes #55. This is a serious bug, so I want you to respond early.