You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The semantic versioning specification 2.0.0 [states](https://semver.org/#spec-item-9) that pre-release identifiers must be positioned after the version core, and build metadata identifiers after pre-release identifiers.
In the old implementation, if a version core was appended with metadata identifiers that contain hyphens ("-"), the first hyphen would be mistaken as an indication of pre-release identifiers thereafter. Then, the position of the first hyphen would be treated as where the version core ends, resulting in a false negative after it was found that the "version core" contained non-numeric characters.
For example: the semantic version `1.2.3+some-meta.data` is a well-formed, with `1.2.3` being the version core and `some-meta.data` the metadata identifiers. However, the old implementation of `Version.init?(_ versionString: String)` would falsely treat `1.2.3+some` as the version core and `meta.data` the pre-release identifiers.
The new implementation fixes this problem by restricting the search area for "+" to the substring after the first "-".
In addition, the logic for breaking up the version core into numeric identifiers has been rewritten to be more understandable.
---
Currently, the test fails because of a problem with overloaded initialisers (`Version.init(_ version: Version)` and `Version.init?(_ versionString: String`). After this problem is resolved, a new commit containing a complete set of test cases is likely to be squashed into this one.
// SemVer 2.0.0 allows only ASCII alphanumerical characters and "-" in the version string, except for "." and "+" as delimiters. ("-" is used as a delimiter between the version core and pre-release identifiers, but it's allowed within pre-release and metadata identifiers as well.)
65
+
// Alphanumerics check will come later, after each identifier is split out (i.e. after the delimiters are removed).
0 commit comments