[GH-ISSUE #702] Regex from semver.org not matching 0.0.1-SNAPSHOT.I.0285680 #7449

Closed
opened 2026-06-20 17:31:35 -05:00 by GiteaMirror · 2 comments
Owner

Originally created by @shoelzle on GitHub (May 14, 2021).
Original GitHub issue: https://github.com/semver/semver/issues/702

The version 0.0.1-SNAPSHOT.I.0285680 is not a valid semantic version.
The problem is the 0 after the dot, hence 0.0.1-SNAPSHOT.I.1285680 matches just fine.

But why must multiple digits in a numeric identifier not start with a zero ?

The relevant part from the semver.org BNF:

<numeric identifier> ::= "0"
                       | <positive digit>
                       | <positive digit> <digits>
Originally created by @shoelzle on GitHub (May 14, 2021). Original GitHub issue: https://github.com/semver/semver/issues/702 The version `0.0.1-SNAPSHOT.I.0285680` is not a valid semantic version. The problem is the `0` after the dot, hence `0.0.1-SNAPSHOT.I.1285680` matches just fine. But why must *multiple* digits in a numeric identifier not start with a zero ? The relevant part from the semver.org BNF: ``` <numeric identifier> ::= "0" | <positive digit> | <positive digit> <digits> ```
Author
Owner

@dtonhofer commented on GitHub (May 17, 2021):

I would say, because if it's a number, it should be written canonically, without any leading zeros.

<!-- gh-comment-id:842618725 --> @dtonhofer commented on GitHub (May 17, 2021): I would say, because if it's a number, it should be written canonically, without any leading zeros.
Author
Owner

@shoelzle commented on GitHub (May 19, 2021):

My mistake:
The suffix 0285680 is an example of a short commit sha and as such it is just not semver compliant to put it in the pre-release part of the BNF because it is not a numeric identifier. But it is a build identifier, so the following versions are semver compliant:

  • 0.0.1-SNAPSHOT+I.0285680
  • 0.0.1-SNAPSHOT+I.1285680

Thanks for the hint.

<!-- gh-comment-id:844381773 --> @shoelzle commented on GitHub (May 19, 2021): My mistake: The suffix `0285680` is an example of a short commit sha and as such it is just not semver compliant to put it in the `pre-release` part of the BNF because it is not a `numeric identifier`. But it is a `build identifier`, so the following versions are semver compliant: * `0.0.1-SNAPSHOT+I.0285680` * `0.0.1-SNAPSHOT+I.1285680` Thanks for the hint.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/semver#7449