diff --git a/src/tools/browser.rs b/src/tools/browser.rs index 93b4399..b3709f6 100644 --- a/src/tools/browser.rs +++ b/src/tools/browser.rs @@ -790,6 +790,25 @@ mod tests { ); } + #[test] + fn extract_host_handles_ipv6() { + // IPv6 with brackets (required for URLs with ports) + assert_eq!( + extract_host("https://[::1]/path").unwrap(), + "[::1]" + ); + // IPv6 with brackets and port + assert_eq!( + extract_host("https://[2001:db8::1]:8080/path").unwrap(), + "[2001:db8::1]" + ); + // IPv6 with brackets, trailing slash + assert_eq!( + extract_host("https://[fe80::1]/").unwrap(), + "[fe80::1]" + ); + } + #[test] fn is_private_host_detects_local() { assert!(is_private_host("localhost"));