authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2026-01-22 01:59:53 -08:00
committergravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2026-01-22 02:52:27 -08:00
logca8288e4d4de7ccc388ddcfe8305c05614cf63bf
tree216678883544aa3d33908f3477323523624a8420
parentb10e5ab46dcb145722cc08522c824a5aa06e4948

└─ run test 511/542 passed, 4 failed, 27 skipped


4 files changed, 9 insertions(+), 3 deletions(-)

generate.ts-1
......@@ -1,4 +1,3 @@
1import { closeSync, openSync } from "node:fs";
21import casesraw from "./urltestdata.json";
32import casesidna from "./IdnaTestV2.json";
43
licenses.txt+2
......@@ -3,12 +3,14 @@ MPL-2.0:
33- This
44- git https://github.com/nektro/zig-net
55- git https://github.com/nektro/zig-nio
6- git https://github.com/nektro/zig-unicode-idna
67
78MIT:
89= https://spdx.org/licenses/MIT
910- git https://github.com/nektro/zig-expect
1011- git https://github.com/nektro/zig-extras
1112- git https://github.com/nektro/zig-sys-linux
13- git https://github.com/nektro/zig-unicode-ucd
1214
1315Unspecified:
1416- system_lib c
url.zig+6-2
......@@ -2,6 +2,7 @@ const std = @import("std");
22const builtin = @import("builtin");
33const net = @import("net");
44const extras = @import("extras");
5const unicode_idna = @import("unicode-idna");
56
67pub const URL = struct {
78 href: []const u8,
......@@ -448,6 +449,7 @@ pub const URL = struct {
448449 },
449450 .file => {
450451 // 1. Set url’s scheme to "file".
452 scheme.clearRetainingCapacity();
451453 try scheme.appendSlice("file");
452454 // 2. Set url’s host to the empty string.
453455 host = .{ .name = "" };
......@@ -1057,9 +1059,11 @@ fn percentDecode(allocator: std.mem.Allocator, input: []const u8) ![]u8 {
10571059}
10581060
10591061/// https://url.spec.whatwg.org/#concept-domain-to-ascii
1060// TODO:
10611062fn domainToAscii(allocator: std.mem.Allocator, domain: []const u8, beStrict: bool) ![]u8 {
1062 const result = try allocator.dupe(u8, domain);
1063 const result = unicode_idna.ToASCII(allocator, domain, beStrict, true, true, beStrict, false, beStrict, false) catch |err| switch (err) {
1064 error.IDNAFailure => return error.InvalidURL,
1065 error.OutOfMemory => return error.OutOfMemory,
1066 };
10631067 errdefer allocator.free(result);
10641068 if (!beStrict) {
10651069 if (result.len == 0) return error.InvalidURL;
zigmod.yml+1
......@@ -6,5 +6,6 @@ description: A WHATWG URL-compatible parser for Zig
66dependencies:
77 - src: git https://github.com/nektro/zig-net
88 - src: git https://github.com/nektro/zig-extras
9 - src: git https://github.com/nektro/zig-unicode-idna
910root_dependencies:
1011 - src: git https://github.com/nektro/zig-expect