Problem
Context: I am writing a new 3rd party registry implementation (https://github.com/pulp/pulp_rust)
Cargo fetches the registry URL from the "api" field of config.json, but doesn't modify it by e.g. removing trailing slashes - therefore if a trailing slash exists, cargo publish will emit requests to https://example.com/registry//api/v1/crates/new
crates.io seems to accept this (and never emits "api" with a trailing slash in the first place), so in that case it's not much of an issue - but it would be good for cargo to handle this better anyway.
Steps
No response
Possible Solution(s)
Change
pub fn new_handle(
host: String,
token: Option<String>,
handle: Easy,
auth_required: bool,
) -> Registry {
Registry {
host,
token,
handle,
auth_required,
}
}
to
pub fn new_handle(
host: String,
token: Option<String>,
handle: Easy,
auth_required: bool,
) -> Registry {
Registry {
host: host.trim_end_matches('/').to_string()),
token,
handle,
auth_required,
}
}
here
Notes
No response
Version
cargo 1.94.0 (85eff7c80 2026-01-15)
release: 1.94.0
commit-hash: 85eff7c80277b57f78b11e28d14154ab12fcf643
commit-date: 2026-01-15
host: x86_64-unknown-linux-gnu
libgit2: 1.9.2 (sys:0.20.3 vendored)
libcurl: 8.17.0-DEV (sys:0.4.84+curl-8.17.0 vendored ssl:OpenSSL/3.5.4)
ssl: OpenSSL 3.5.4 30 Sep 2025
os: Fedora 43.0.0 [64-bit]
Problem
Context: I am writing a new 3rd party registry implementation (https://github.com/pulp/pulp_rust)
Cargo fetches the registry URL from the
"api"field ofconfig.json, but doesn't modify it by e.g. removing trailing slashes - therefore if a trailing slash exists,cargo publishwill emit requests tohttps://example.com/registry//api/v1/crates/newcrates.io seems to accept this (and never emits
"api"with a trailing slash in the first place), so in that case it's not much of an issue - but it would be good for cargo to handle this better anyway.Steps
No response
Possible Solution(s)
Change
to
here
Notes
No response
Version