Repository navigation
fix: accept alphanumeric pre-release identifiers with leading zeros - #322
Open
AdamMagued wants to merge 1 commit into
Open
AdamMagued wants to merge 1 commit into
AdamMagued wants to merge 1 commit into
Conversation
SemVer 2.0.0 specification section 9 disallows leading zeros only on purely numeric identifiers, while alphanumeric identifiers (containing at least one non-digit) are permitted to have leading zeros (e.g. 0f9a5fdef). Document this distinction in validatePrerelease and add regression tests in version_test.go and constraints_test.go for valid alphanumeric pre-releases starting with 0 followed by letters (e.g. 0.0.1-0f9a5fdef.38). Fixes Masterminds#272
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Under Section 9 of the SemVer 2.0.0 specification:
"Numeric identifiers MUST NOT include leading zeroes."
Alphanumeric identifiers (those containing at least one non-digit character such as ASCII letters or hyphens) are not subject to this restriction and may begin with leading zeroes (e.g., 0f9a5fdef, 0abc, 0-1, 00a).
This PR documents this distinction in validatePrerelease and adds regression test coverage across NewVersion, StrictNewVersion, validatePrerelease, and NewConstraint for version strings with valid alphanumeric pre-release identifiers starting with zeros, including 0.0.1-0f9a5fdef.38.
Fixes #272