[BUG] Coercing version with prerelease identifier that starts with digits returns truncated identifier (original) (raw)

Is there an existing issue for this?

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:

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:

Expected Behavior

The prerelease identifier isn't truncated.

Steps To Reproduce

  1. Clone the reproduction repository: https://github.com/nhedger/semver-prerelease-issue
  2. Install the dependencies
  3. Run node index.mjs
  4. See that the prerelease identifier is truncated

Environment