From 0b13565e2f8e96e594f26885cc9bfc92162b1a0f Mon Sep 17 00:00:00 2001 From: Meghan Denny Date: Wed, 4 Feb 2026 18:11:14 -0800 Subject: [PATCH] add URL.hostFancy() --- url.zig | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/url.zig b/url.zig index 64a00c1951659f4fb1aff258a345e45835f50991..ef1886b5ed014101bcad927e1c984e1ceba6d1af 100644 --- a/url.zig +++ b/url.zig @@ -951,6 +951,15 @@ pub const URL = struct { if (u.hash.len == 0) return ""; return u.hash[1..]; // hash includes '#' } + + pub fn hostFancy(u: *const URL) Host { + return switch (u.hostname_kind) { + .unset => .{ .unset = {} }, + .name => .{ .name = u.hostname }, + .ipv4 => .{ .ipv4 = parseIPv4(u.hostname) catch unreachable }, + .ipv6 => .{ .ipv6 = parseIPv6(u.hostname[1 .. u.hostname.len - 1]) catch unreachable }, + }; + } }; /// https://url.spec.whatwg.org/#special-scheme -- 2.54.0