diff --git a/compliance-agent/src/pipeline/orchestrator.rs b/compliance-agent/src/pipeline/orchestrator.rs index ead8f6e..82fa5e8 100644 --- a/compliance-agent/src/pipeline/orchestrator.rs +++ b/compliance-agent/src/pipeline/orchestrator.rs @@ -914,27 +914,15 @@ impl PipelineOrchestrator { /// e.g. "https://gitea.example.com/owner/repo.git" → "https://gitea.example.com" /// e.g. "ssh://git@gitea.example.com:22/owner/repo.git" → "https://gitea.example.com" fn extract_base_url(git_url: &str) -> Option { - if git_url.starts_with("http://") || git_url.starts_with("https://") { - // https://host/path... → take scheme + host - let without_scheme = if git_url.starts_with("https://") { - &git_url[8..] - } else { - &git_url[7..] - }; - let host = without_scheme.split('/').next()?; - let scheme = if git_url.starts_with("https://") { - "https" - } else { - "http" - }; - Some(format!("{scheme}://{host}")) - } else if git_url.starts_with("ssh://") { + if let Some(rest) = git_url.strip_prefix("https://") { + let host = rest.split('/').next()?; + Some(format!("https://{host}")) + } else if let Some(rest) = git_url.strip_prefix("http://") { + let host = rest.split('/').next()?; + Some(format!("http://{host}")) + } else if let Some(rest) = git_url.strip_prefix("ssh://") { // ssh://git@host:port/path → extract host - let after_scheme = &git_url[6..]; - let after_at = after_scheme - .find('@') - .map(|i| &after_scheme[i + 1..]) - .unwrap_or(after_scheme); + let after_at = rest.find('@').map(|i| &rest[i + 1..]).unwrap_or(rest); let host = after_at.split(&[':', '/'][..]).next()?; Some(format!("https://{host}")) } else if let Some(at_pos) = git_url.find('@') { diff --git a/compliance-dashboard/src/infrastructure/repositories.rs b/compliance-dashboard/src/infrastructure/repositories.rs index c684522..60bdd7c 100644 --- a/compliance-dashboard/src/infrastructure/repositories.rs +++ b/compliance-dashboard/src/infrastructure/repositories.rs @@ -30,6 +30,7 @@ pub async fn fetch_repositories(page: u64) -> Result &'static str { #[cfg(feature = "web")] fn trigger_download(content: &str, filename: &str) { use wasm_bindgen::JsCast; - let window = web_sys::window().expect("no window"); - let document = window.document().expect("no document"); + let Some(window) = web_sys::window() else { + return; + }; + let Some(document) = window.document() else { + return; + }; let blob_parts = js_sys::Array::new(); blob_parts.push(&wasm_bindgen::JsValue::from_str(content)); - let mut opts = web_sys::BlobPropertyBag::new(); - opts.type_("application/json"); - let blob = web_sys::Blob::new_with_str_sequence_and_options(&blob_parts, &opts).expect("blob"); + let opts = web_sys::BlobPropertyBag::new(); + opts.set_type("application/json"); + let Ok(blob) = web_sys::Blob::new_with_str_sequence_and_options(&blob_parts, &opts) else { + return; + }; - let url = web_sys::Url::create_object_url_with_blob(&blob).expect("object url"); + let Ok(url) = web_sys::Url::create_object_url_with_blob(&blob) else { + return; + }; - let a: web_sys::HtmlAnchorElement = document - .create_element("a") - .expect("create a") - .dyn_into() - .expect("cast"); + let Ok(el) = document.create_element("a") else { + return; + }; + let Ok(a) = el.dyn_into::() else { + return; + }; a.set_href(&url); a.set_download(filename); a.click();