authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2026-01-12 02:01:34 -08:00
committergravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2026-01-12 02:01:34 -08:00
logb10e5ab46dcb145722cc08522c824a5aa06e4948
tree668d983aa0d8b573e4b896f7204d1a6f20e22281
parentd35b99f6018c3ccca853286087a7ef074d4be71b

└─ run test 499/543 passed, 17 failed, 27 skipped


1 files changed, 18 insertions(+), 2 deletions(-)

url.zig+18-2
...@@ -1059,8 +1059,16 @@ fn percentDecode(allocator: std.mem.Allocator, input: []const u8) ![]u8 {...@@ -1059,8 +1059,16 @@ fn percentDecode(allocator: std.mem.Allocator, input: []const u8) ![]u8 {
1059/// https://url.spec.whatwg.org/#concept-domain-to-ascii1059/// https://url.spec.whatwg.org/#concept-domain-to-ascii
1060// TODO:1060// TODO:
1061fn domainToAscii(allocator: std.mem.Allocator, domain: []const u8, beStrict: bool) ![]u8 {1061fn domainToAscii(allocator: std.mem.Allocator, domain: []const u8, beStrict: bool) ![]u8 {
1062 _ = beStrict;1062 const result = try allocator.dupe(u8, domain);
1063 return allocator.dupe(u8, domain);1063 errdefer allocator.free(result);
1064 if (!beStrict) {
1065 if (result.len == 0) return error.InvalidURL;
1066 if (extras.matchesAny(u8, result, is_forbidden_domain_codepoint)) return error.InvalidURL;
1067 return result;
1068 }
1069 std.debug.assert(result.len > 0);
1070 std.debug.assert(!extras.matchesAny(u8, result, is_forbidden_domain_codepoint));
1071 return result;
1064}1072}
10651073
1066// https://url.spec.whatwg.org/#ends-in-a-number-checker1074// https://url.spec.whatwg.org/#ends-in-a-number-checker
...@@ -1227,6 +1235,14 @@ fn is_forbidden_host_codepoint(c: u8) bool {...@@ -1227,6 +1235,14 @@ fn is_forbidden_host_codepoint(c: u8) bool {
1227 if (c == '|') return true;1235 if (c == '|') return true;
1228 return false;1236 return false;
1229}1237}
1238/// https://url.spec.whatwg.org/#forbidden-domain-code-point
1239fn is_forbidden_domain_codepoint(c: u8) bool {
1240 if (is_forbidden_host_codepoint(c)) return true;
1241 if (is_c0control(c)) return true;
1242 if (c == '%') return true;
1243 if (c == 0x7f) return true;
1244 return false;
1245}
1230/// https://url.spec.whatwg.org/#url-code-points1246/// https://url.spec.whatwg.org/#url-code-points
1231fn is_url_codepoint(c: u21) bool {1247fn is_url_codepoint(c: u21) bool {
1232 if (c < 128 and std.ascii.isAlphanumeric(@intCast(c))) return true;1248 if (c < 128 and std.ascii.isAlphanumeric(@intCast(c))) return true;