| ... | ... | @@ -977,6 +977,30 @@ pub const URL = struct { |
| 977 | 977 | pub fn searchParams(u: *const URL, allocator: std.mem.Allocator) !SearchParams { |
| 978 | 978 | return .initFromString(allocator, u.query()); |
| 979 | 979 | } |
| 980 | |
| 981 | pub fn isHostLocal(u: *const URL) bool { |
| 982 | switch (u.hostFancy()) { |
| 983 | .unset => { |
| 984 | return false; |
| 985 | }, |
| 986 | .name => |nm| { |
| 987 | if (std.mem.eql(u8, nm, "localhost")) return true; |
| 988 | if (std.mem.endsWith(u8, nm, ".localhost")) return true; |
| 989 | if (std.mem.endsWith(u8, nm, ".test")) return true; |
| 990 | if (std.mem.endsWith(u8, nm, ".example")) return true; |
| 991 | if (std.mem.endsWith(u8, nm, ".invalid")) return true; |
| 992 | if (std.mem.endsWith(u8, nm, ".home.arpa")) return true; |
| 993 | if (std.mem.endsWith(u8, nm, ".local")) return true; |
| 994 | return false; |
| 995 | }, |
| 996 | .ipv4 => { |
| 997 | return false; // TODO |
| 998 | }, |
| 999 | .ipv6 => { |
| 1000 | return false; // TODO |
| 1001 | }, |
| 1002 | } |
| 1003 | } |
| 980 | 1004 | }; |
| 981 | 1005 | |
| 982 | 1006 | pub const SearchParams = struct { |