-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix scanning of a pre-release starting with 0
A pre-release "Numeric identifiers MUST NOT include leading zeroes," according to SemVer 2.0. The existing code had accounted for this limitation: when it found a pre-release starting with a 0 followed by a digit, it would scan ahead and allow the value if it found an alphabetic character. There were two bugs in the Implementation. First, in addition to alphabetic characters, SemVer allows dashes. The [project regex] matches `[a-zA-Z-]`. So add a check for a dash in addition to `isalpha()`. Thanks to Dylan Bourque for the pull request (#70). The other bug was that the scanning was was not starting from the character after the zero and following digit. It was, instead, starting from that position subtracted from the length. For example, if the pre-release started at character 7 and the semver was 12 characters long, it would start scanning at character 13, well *after* the start of the pre-release. If the pre-release started at character 8 and the semver was 12 characters long, it would start scanning from character 4, well *before* the start of the pre-release. It's a wonder no errors were previously discovered. Fix it by starting from the current character, and include some details in Changes to help find existing bad values.
- Loading branch information
Showing
4 changed files
with
70 additions
and
49 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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