Closed
Description
Is there an existing issue for this?
- I have searched the existing issues
Current Behavior
Using semver 7.7.1
(and possibly earlier versions), attempting to coerce a version string that contains a prerelease identifier that starts with digits, will result in that identifier to be truncated after the digits.
Here are some example:
1.0.0-alpha.1ab
produces1.0.0-alpha.1
1.0.0-alpha.12ab
produces1.0.0-alpha.12
1.0.0-alpha.1234.23cd
produces1.0.0-alpha.1234.23
This is problematic when the identifier is a hash that may start with a digit.
The issue doesn't seem to happen if the identifier is composed of only number, or if the identifier starts with an alphabetic character:
1.9.5-nightly.abc123
is coerced as expected1.9.5-nightly.abcdef
is coerced as expected1.9.5-nightly.123456
is coerced as expected
Expected Behavior
The prerelease identifier isn't truncated.
Steps To Reproduce
- Clone the reproduction repository: https://github.com/nhedger/semver-prerelease-issue
- Install the dependencies
- Run
node index.mjs
- See that the prerelease identifier is truncated
Environment
- npm: 10.8.2
- Node: 20.17.0
- OS: macOS
- platform: MacBook Pro M1