Skip to content

Commit c6e4783

Browse files
authored
fix(verify): handle lack of trailing slash in verifier url (#12806)
Closes #12802
1 parent a71243b commit c6e4783

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/verify/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ semver.workspace = true
4040
regex = { workspace = true, default-features = false }
4141
yansi.workspace = true
4242
itertools.workspace = true
43+
url.workspace = true
4344

4445
[dev-dependencies]
4546
tokio = { workspace = true, features = ["macros"] }

crates/verify/src/sourcify.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ use futures::FutureExt;
1616
use reqwest::StatusCode;
1717
use serde::{Deserialize, Serialize};
1818
use std::path::Path;
19+
use url::Url;
1920

2021
pub static SOURCIFY_URL: &str = "https://sourcify.dev/server/";
2122

@@ -187,8 +188,11 @@ impl VerificationProvider for SourcifyVerificationProvider {
187188
}
188189

189190
impl SourcifyVerificationProvider {
190-
fn get_base_url(verifier_url: Option<&str>) -> &str {
191-
verifier_url.unwrap_or(SOURCIFY_URL)
191+
fn get_base_url(verifier_url: Option<&str>) -> Url {
192+
// note(onbjerg): a little ugly but makes this infallible as we guarantee `SOURCIFY_URL` to
193+
// be well formatted
194+
Url::parse(verifier_url.unwrap_or(SOURCIFY_URL))
195+
.unwrap_or_else(|_| Url::parse(SOURCIFY_URL).unwrap())
192196
}
193197

194198
fn get_verify_url(

0 commit comments

Comments
 (0)