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 @@...@@ -1,4 +1,3 @@
1import { closeSync, openSync } from "node:fs";
2import casesraw from "./urltestdata.json";1import casesraw from "./urltestdata.json";
3import casesidna from "./IdnaTestV2.json";2import casesidna from "./IdnaTestV2.json";
43
licenses.txt+2
...@@ -3,12 +3,14 @@ MPL-2.0:...@@ -3,12 +3,14 @@ MPL-2.0:
3- This3- This
4- git https://github.com/nektro/zig-net4- git https://github.com/nektro/zig-net
5- git https://github.com/nektro/zig-nio5- git https://github.com/nektro/zig-nio
6- git https://github.com/nektro/zig-unicode-idna
67
7MIT:8MIT:
8= https://spdx.org/licenses/MIT9= https://spdx.org/licenses/MIT
9- git https://github.com/nektro/zig-expect10- git https://github.com/nektro/zig-expect
10- git https://github.com/nektro/zig-extras11- git https://github.com/nektro/zig-extras
11- git https://github.com/nektro/zig-sys-linux12- git https://github.com/nektro/zig-sys-linux
13- git https://github.com/nektro/zig-unicode-ucd
1214
13Unspecified:15Unspecified:
14- system_lib c16- system_lib c
url.zig+6-2
...@@ -2,6 +2,7 @@ const std = @import("std");...@@ -2,6 +2,7 @@ const std = @import("std");
2const builtin = @import("builtin");2const builtin = @import("builtin");
3const net = @import("net");3const net = @import("net");
4const extras = @import("extras");4const extras = @import("extras");
5const unicode_idna = @import("unicode-idna");
56
6pub const URL = struct {7pub const URL = struct {
7 href: []const u8,8 href: []const u8,
...@@ -448,6 +449,7 @@ pub const URL = struct {...@@ -448,6 +449,7 @@ pub const URL = struct {
448 },449 },
449 .file => {450 .file => {
450 // 1. Set url’s scheme to "file".451 // 1. Set url’s scheme to "file".
452 scheme.clearRetainingCapacity();
451 try scheme.appendSlice("file");453 try scheme.appendSlice("file");
452 // 2. Set url’s host to the empty string.454 // 2. Set url’s host to the empty string.
453 host = .{ .name = "" };455 host = .{ .name = "" };
...@@ -1057,9 +1059,11 @@ fn percentDecode(allocator: std.mem.Allocator, input: []const u8) ![]u8 {...@@ -1057,9 +1059,11 @@ fn percentDecode(allocator: std.mem.Allocator, input: []const u8) ![]u8 {
1057}1059}
10581060
1059/// https://url.spec.whatwg.org/#concept-domain-to-ascii1061/// https://url.spec.whatwg.org/#concept-domain-to-ascii
1060// TODO:
1061fn domainToAscii(allocator: std.mem.Allocator, domain: []const u8, beStrict: bool) ![]u8 {1062fn 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 };
1063 errdefer allocator.free(result);1067 errdefer allocator.free(result);
1064 if (!beStrict) {1068 if (!beStrict) {
1065 if (result.len == 0) return error.InvalidURL;1069 if (result.len == 0) return error.InvalidURL;
zigmod.yml+1
...@@ -6,5 +6,6 @@ description: A WHATWG URL-compatible parser for Zig...@@ -6,5 +6,6 @@ description: A WHATWG URL-compatible parser for Zig
6dependencies:6dependencies:
7 - src: git https://github.com/nektro/zig-net7 - src: git https://github.com/nektro/zig-net
8 - src: git https://github.com/nektro/zig-extras8 - src: git https://github.com/nektro/zig-extras
9 - src: git https://github.com/nektro/zig-unicode-idna
9root_dependencies:10root_dependencies:
10 - src: git https://github.com/nektro/zig-expect11 - src: git https://github.com/nektro/zig-expect