Semver icon

Semver

Semantic Versioning utilities for version management

Overview

This node provides utilities for cleaning and normalizing semantic version strings. Specifically, the "Cleaning" resource with the "Clean" operation takes a version string input and returns a cleaned, normalized version of it according to semantic versioning rules.

This is useful in scenarios where version strings may have inconsistent formatting or extraneous characters, and you want to standardize them before further processing or comparison. For example, if you receive version inputs from various sources that might include whitespace or non-standard formatting, this node can clean those strings into a consistent semver format.

Practical examples:

  • Cleaning user input version strings before storing them in a database.
  • Normalizing versions extracted from package manifests or API responses.
  • Preparing version strings for reliable comparison or sorting operations downstream.

Properties

Name Meaning
Version The version string to process. Example: "1.2.3", "v1.2.3-beta", or " 1.2.3 "
Options Collection of options to customize cleaning behavior:
- Loose Boolean flag to enable loose parsing of version strings (allows more flexible formats).
- Include Prerelease Boolean flag to include prerelease versions in range matching (not used here).
- RTL (Right to Left) Boolean flag to coerce version strings right to left (not applicable here).

For the Cleaning resource and Clean operation, only the "Version" and "Options.Loose" are relevant.

Output

The output JSON contains the following fields:

  • operation: Always "clean" indicating the performed operation.
  • version: The original input version string.
  • result: The cleaned and normalized version string according to semantic versioning rules.

Example output JSON snippet:

{
  "operation": "clean",
  "version": " v1.2.3-beta ",
  "result": "1.2.3-beta"
}

No binary data output is produced by this node.

Dependencies

  • This node depends on the external semver library for all semantic version parsing and cleaning logic.
  • No external API keys or services are required.
  • No special environment variables or n8n credentials are needed.

Troubleshooting

  • Invalid version strings: If the input version string is not a valid semantic version, the cleaning result may be null or an empty string. Ensure the input follows semver conventions or enable the "Loose" option for more permissive parsing.
  • Empty results: If the cleaned version is empty, verify that the input version string is not empty or malformed.
  • Error messages: Errors thrown by the underlying semver library will be surfaced. Common errors relate to invalid version formats. To resolve, check and correct the input version string format.

Links and References

Discussion