From 8db64772b78a847cec95b7fd806e92a0b6ec84fa Mon Sep 17 00:00:00 2001 From: Muki Kiboigo Date: Thu, 12 Mar 2026 09:02:48 -0700 Subject: [PATCH] add URL getHost test --- src/browser/URL.zig | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/browser/URL.zig b/src/browser/URL.zig index 19b87333..996f69d2 100644 --- a/src/browser/URL.zig +++ b/src/browser/URL.zig @@ -1400,3 +1400,12 @@ test "URL: unescape" { try testing.expectEqual("hello%2", result); } } + +test "URL: getHost" { + try testing.expectEqualSlices(u8, "example.com:8080", getHost("https://example.com:8080/path")); + try testing.expectEqualSlices(u8, "example.com", getHost("https://example.com/path")); + try testing.expectEqualSlices(u8, "example.com:443", getHost("https://example.com:443/")); + try testing.expectEqualSlices(u8, "example.com", getHost("https://user:pass@example.com/page")); + try testing.expectEqualSlices(u8, "example.com:8080", getHost("https://user:pass@example.com:8080/page")); + try testing.expectEqualSlices(u8, "", getHost("not-a-url")); +}