Skip to main content

normalize_version

Function normalize_version 

Source
pub fn normalize_version(version: &str) -> String
Expand description

Normalize a user-supplied version string for docs.rs URL construction.

Trims surrounding whitespace and strips a single leading v/V when it is immediately followed by a digit (e.g. v1.2.3 -> 1.2.3). crates.io and docs.rs versions are plain semver and never carry a v prefix, but users routinely copy versions from git tags or changelogs where that prefix is conventional; without this they hit a confusing 400/404. Non-version identifiers such as latest (no leading-v-before-digit) are unchanged.