From 40eab41b2b5f6428c155c575bbc330ac7999c130 Mon Sep 17 00:00:00 2001 From: Simon Date: Sat, 10 Oct 2026 09:36:13 +0000 Subject: [PATCH] Fix hanime-cdn relative path prefixing and stale vidara test Co-Authored-By: Claude Sonnet 5.5 Claude-Session: https://claude.ai/code/session_01MUYdCh2nCVsQYgJAT7gwSi --- src/proxies/hanimecdn.rs | 10 +++++++++- src/proxies/vidara.rs | 11 ++++++++--- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/proxies/hanimecdn.rs b/src/proxies/hanimecdn.rs index f619bbf..1f445c7 100644 --- a/src/proxies/hanimecdn.rs +++ b/src/proxies/hanimecdn.rs @@ -12,8 +12,16 @@ fn normalize_image_url(endpoint: &str) -> String { endpoint.to_string() } else if endpoint.starts_with("hanime-cdn.com/") || endpoint == "hanime-cdn.com" { format!("https://{endpoint}") - } else { + } else if endpoint + .split('/') + .next() + .is_some_and(|first| first.contains('.')) + { + // `other-host.tld/path`: the caller already supplied a host. format!("https://{endpoint}") + } else { + // Site-relative path such as `images/covers/x.png`. + format!("https://hanime-cdn.com/{endpoint}") } } diff --git a/src/proxies/vidara.rs b/src/proxies/vidara.rs index 1f2ceff..bcce7d0 100644 --- a/src/proxies/vidara.rs +++ b/src/proxies/vidara.rs @@ -116,9 +116,14 @@ mod tests { #[test] fn normalizes_detail_request_with_path_only() { - let (url, video_id) = VidaraProxy::normalize_detail_request("video/1000/demo") + let (url, video_id) = VidaraProxy::normalize_detail_request("v/eJ9O4QqG1Ln2") .expect("detail request should parse"); - assert_eq!(url, "https://vidara.so/video/1000/demo"); - assert_eq!(video_id, "1000"); + assert_eq!(url, "https://vidara.so/v/eJ9O4QqG1Ln2"); + assert_eq!(video_id, "eJ9O4QqG1Ln2"); + } + + #[test] + fn rejects_paths_outside_the_embed_route() { + assert!(VidaraProxy::normalize_detail_request("video/1000/demo").is_none()); } }