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 {
10591059/// https://url.spec.whatwg.org/#concept-domain-to-ascii
10601060// TODO:
10611061fn domainToAscii(allocator: std.mem.Allocator, domain: []const u8, beStrict: bool) ![]u8 {
1062 _ = beStrict;
1063 return allocator.dupe(u8, domain);
1062 const result = try 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;
10641072}
10651073
10661074// https://url.spec.whatwg.org/#ends-in-a-number-checker
......@@ -1227,6 +1235,14 @@ fn is_forbidden_host_codepoint(c: u8) bool {
12271235 if (c == '|') return true;
12281236 return false;
12291237}
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}
12301246/// https://url.spec.whatwg.org/#url-code-points
12311247fn is_url_codepoint(c: u21) bool {
12321248 if (c < 128 and std.ascii.isAlphanumeric(@intCast(c))) return true;