authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2026-02-04 18:11:14 -08:00
committergravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2026-02-04 18:11:14 -08:00
log0b13565e2f8e96e594f26885cc9bfc92162b1a0f
treebd088ac40671554d622d0d0af53796c0f36c5403
parent37028e958fd0a59763d302845afe7cada80155bd

add URL.hostFancy()


1 files changed, 9 insertions(+), 0 deletions(-)

url.zig+9
......@@ -951,6 +951,15 @@ pub const URL = struct {
951951 if (u.hash.len == 0) return "";
952952 return u.hash[1..]; // hash includes '#'
953953 }
954
955 pub fn hostFancy(u: *const URL) Host {
956 return switch (u.hostname_kind) {
957 .unset => .{ .unset = {} },
958 .name => .{ .name = u.hostname },
959 .ipv4 => .{ .ipv4 = parseIPv4(u.hostname) catch unreachable },
960 .ipv6 => .{ .ipv6 = parseIPv6(u.hostname[1 .. u.hostname.len - 1]) catch unreachable },
961 };
962 }
954963};
955964
956965/// https://url.spec.whatwg.org/#special-scheme