| ... | ... | @@ -951,6 +951,15 @@ pub const URL = struct { |
| 951 | 951 | if (u.hash.len == 0) return ""; |
| 952 | 952 | return u.hash[1..]; // hash includes '#' |
| 953 | 953 | } |
| 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 | } |
| 954 | 963 | }; |
| 955 | 964 | |
| 956 | 965 | /// https://url.spec.whatwg.org/#special-scheme |