Skip to content
Starlight Plugin Show Latest Version Loading...

Version Extraction Algorithm

The Starlight Plugin Show Latest Version plugin fetches the latest release of your package as specified in the source configuration option.

Regex Pattern

The Starlight Plugin Show Latest Version plugin uses a regex pattern to extract the version (and prerelease). The default pattern is:

/^(?:v|[^0-9\s]*@)?v?(?<version>[0-9]+\.[0-9]+\.[0-9]+)(?:-(?<prerelease>[0-9A-Za-z]+(?:\.[0-9A-Za-z]+)*))?(?![-.]|[^-\w.])$/;

You can override the pattern using the regexPattern configuration option.

Supported tag_names

The tag_name can be one of the following formats which will produce these badges:

Invalid tag_names

Here are examples of tag_name formats which would not be supported by the default version extraction algorithm:

  • 1.2 → no semantic versioning because it is missing the third number
  • v1.2 → no semantic versioning because it is missing the third number
  • 1.2. → invalid version format, incomplete
  • v1.2. → invalid version format, incomplete
  • 1.2.3.4 → too many version segments
  • 1.2.3. → invalid version format, trailing dot
  • v1.2.3.4 → too many version segments
  • 1.2.3- → invalid prerelease format
  • 1.2.3-.rc → invalid prerelease format
  • 1.2.3-rc. → invalid prerelease format
  • 1.2.3--rc → invalid prerelease format
  • random-text → non-version string
  • → empty string
  • 123 → non-version string
  • v1.2.3-special!char → invalid version format with special characters
  • 1.2.3-pre release → invalid version format due to space