Skip to content

fix: accept alphanumeric pre-release identifiers with leading zeros - #322

Open
AdamMagued wants to merge 1 commit into
Masterminds:masterfrom
AdamMagued:fix-alphanumeric-prerelease-leading-zero
Open

AdamMagued wants to merge 1 commit into
Masterminds:masterfrom
AdamMagued:fix-alphanumeric-prerelease-leading-zero

Conversation

@AdamMagued

Copy link
Copy Markdown

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

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
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.

semver fails to accept pre-release starting with '0f' (e.g. 0.0.1-0f9a5fdef.38) – valid SemVer rejected

1 participant