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

Fix ParseTolerant when zeros are continuous #56

Merged
merged 1 commit into from
May 24, 2020

Conversation

Songmu
Copy link
Contributor

@Songmu Songmu commented May 28, 2019

It fixes #55. This is a serious bug, so I want you to respond early.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 100.0% when pulling 6e788bb on Songmu:fix-parsetolerant-iss55 into 1a9109f on blang:master.

1 similar comment
@coveralls
Copy link

Coverage Status

Coverage remained the same at 100.0% when pulling 6e788bb on Songmu:fix-parsetolerant-iss55 into 1a9109f on blang:master.

@Songmu
Copy link
Contributor Author

Songmu commented Jun 3, 2019

@blang How about it?

@lootek
Copy link

lootek commented Sep 5, 2019

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") {
Copy link
Contributor

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) {

Copy link
Contributor

@ferhatelmas ferhatelmas left a comment

Choose a reason for hiding this comment

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

LGTM

@blang
Copy link
Owner

blang commented May 24, 2020

Thanks for your contribution and long wait!

@Songmu Songmu deleted the fix-parsetolerant-iss55 branch July 18, 2020 07:53
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.

ParseTolerant now fails on a valid semver
5 participants