Browse Source

Fix parsing return values for zero parts, and allow zero when len(part) == 1

master
GeertJohan 10 years ago
parent
commit
fd83e1645f
1 changed files with 7 additions and 1 deletions
  1. +7
    -1
      version.go

+ 7
- 1
version.go View File

@@ -64,7 +64,10 @@ func parseVersion(s string) (Version, bool) {
return InvalidVersion, false
}
for i, part := range parts {
if len(part) == 0 || part[0] == '0' {
if len(part) == 0 {
return InvalidVersion, false
}
if len(part) > 1 && part[0] == '0' {
return InvalidVersion, false
}
num, err := strconv.ParseInt(part, 10, 32)
@@ -84,5 +87,8 @@ func parseVersion(s string) (Version, bool) {
}
}

if v == InvalidVersion {
return InvalidVersion, false
}
return v, true
}

Loading…
Cancel
Save