We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
When provided an input like a formatted date, this library incorrectly parses it as semver.
package main import ( "fmt" "regexp" ) const ( VersionRegexpRaw string = `v?([0-9]+(\.[0-9]+)*?)` + `(-([0-9]+[0-9A-Za-z\-~]*(\.[0-9A-Za-z\-~]+)*)|(-?([A-Za-z\-~]+[0-9A-Za-z\-~]*(\.[0-9A-Za-z\-~]+)*)))?` + `(\+([0-9A-Za-z\-~]+(\.[0-9A-Za-z\-~]+)*))?` + `?` // SemverRegexpRaw requires a separator between version and prerelease SemverRegexpRaw string = `v?([0-9]+(\.[0-9]+)*?)` + `(-([0-9]+[0-9A-Za-z\-~]*(\.[0-9A-Za-z\-~]+)*)|(-([A-Za-z\-~]+[0-9A-Za-z\-~]*(\.[0-9A-Za-z\-~]+)*)))?` + `(\+([0-9A-Za-z\-~]+(\.[0-9A-Za-z\-~]+)*))?` + `?` ) // mostly from https://semver.org, but v added in front for npm compatibility const validatingRE = `^[v]?(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$` var semverOrgMatcher = regexp.MustCompile(validatingRE) func main() { version := "2020-02-26T7-36-46" versionRegexp := regexp.MustCompile("^" + VersionRegexpRaw + "$") semverRegexp := regexp.MustCompile("^" + SemverRegexpRaw + "$") fmt.Println(versionRegexp.FindStringSubmatch(version)) fmt.Println(semverRegexp.FindStringSubmatch(version)) fmt.Println("is semver according to semver.org:", semverOrgMatcher.MatchString(version)) }
Go playground
I would have expected this to return an error about a malformed version rather than [2020-02-26T7-36-46 2020 -02-26T7-36-46 02-26T7-36-46 ]
[2020-02-26T7-36-46 2020 -02-26T7-36-46 02-26T7-36-46 ]
The text was updated successfully, but these errors were encountered:
No branches or pull requests
When provided an input like a formatted date, this library incorrectly parses it as semver.
Go playground
I would have expected this to return an error about a malformed version rather than
[2020-02-26T7-36-46 2020 -02-26T7-36-46 02-26T7-36-46 ]
The text was updated successfully, but these errors were encountered: