authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2026-01-22 18:59:35 -08:00
committergravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2026-01-22 18:59:35 -08:00
log3b7a4b78acbba53bfeeed122c691ada2c400add4
treee785f18f3e66bf1f50a06d948306268e8f77de3b
parent2d1d8f7da877c6d71a30820361d38949164de1fc

populate hash field


3 files changed, 14 insertions(+), 6 deletions(-)

generate.ts+1-1
......@@ -57,7 +57,7 @@ pub fn parsePass(input: []const u8, base: ?[]const u8, href: []const u8, origin:
5757 try expect(u.port).toEqualString(port);
5858 _ = pathname;
5959 try expect(u.search).toEqualString(search);
60 _ = hash;
60 try expect(u.hash).toEqualString(hash);
6161}
6262
6363pub fn parseIDNAFail(comptime input: []const u8) !void {
url.zig+12-4
......@@ -12,6 +12,7 @@ pub const URL = struct {
1212 password: []const u8,
1313 port: []const u8,
1414 search: []const u8,
15 hash: []const u8,
1516
1617 pub const HostKind = enum {
1718 name,
......@@ -255,6 +256,7 @@ pub const URL = struct {
255256 else if (c == '#') {
256257 href.clear(14);
257258 state = .fragment;
259 try href.appendSlice(13, &.{c});
258260 }
259261 // 4. Otherwise, if c is not the EOF code point:
260262 else if (i < length) {
......@@ -492,6 +494,7 @@ pub const URL = struct {
492494 else if (c == '#') {
493495 href.clear(14);
494496 state = .fragment;
497 try href.appendSlice(13, &.{c});
495498 }
496499 // 4. Otherwise, if c is not the EOF code point:
497500 else if (i < length) {
......@@ -612,6 +615,7 @@ pub const URL = struct {
612615 else if (state_override == null and c == '#') {
613616 href.clear(14);
614617 state = .fragment;
618 try href.appendSlice(13, &.{c});
615619 }
616620 // 4. Otherwise, if c is not the EOF code point:
617621 else if (i < length) {
......@@ -671,6 +675,7 @@ pub const URL = struct {
671675 if (c == '#') {
672676 href.clear(14);
673677 state = .fragment;
678 try href.appendSlice(13, &.{c});
674679 }
675680 }
676681 // 2. Otherwise, run these steps:
......@@ -700,6 +705,7 @@ pub const URL = struct {
700705 else if (c == '#') {
701706 href.clear(14);
702707 state = .fragment;
708 try href.appendSlice(13, &.{c});
703709 }
704710 // 3. Otherwise, if c is U+0020 SPACE:
705711 else if (c == ' ') {
......@@ -747,6 +753,7 @@ pub const URL = struct {
747753 if (c == '#') {
748754 href.clear(14);
749755 state = .fragment;
756 try href.appendSlice(13, &.{c});
750757 }
751758 }
752759 // 3. Otherwise, if c is not the EOF code point:
......@@ -792,6 +799,7 @@ pub const URL = struct {
792799 .password = _href[extras.sum(usize, href.lengths[0..4])..][0..href.lengths[5]],
793800 .port = _href[extras.sum(usize, href.lengths[0..8])..][0..href.lengths[9]],
794801 .search = if (href.lengths[12] == 0) "" else _href[extras.sum(usize, href.lengths[0..11])..][0..extras.sum(usize, href.lengths[11..][0..2])],
802 .hash = if (href.lengths[14] == 0) "" else _href[extras.sum(usize, href.lengths[0..13])..][0..extras.sum(usize, href.lengths[13..][0..2])],
795803 };
796804 return url;
797805 }
......@@ -1385,7 +1393,7 @@ fn percentEncodeScalarAL(list: *std.ArrayList(u8), cp: []const u8, comptime set:
13851393 if (set(cp[0])) {
13861394 for (cp) |b| {
13871395 try list.append('%');
1388 try list.writer().print("{X:0<2}", .{b});
1396 try list.writer().print("{X:0>2}", .{b});
13891397 }
13901398 } else {
13911399 try list.append(cp[0]);
......@@ -1397,7 +1405,7 @@ fn percentEncodeAL(list: *std.ArrayList(u8), input: []const u8, comptime set: fn
13971405 if (set(sl[0])) {
13981406 for (sl) |b| {
13991407 try list.append('%');
1400 try list.writer().print("{X:0<2}", .{b});
1408 try list.writer().print("{X:0>2}", .{b});
14011409 }
14021410 } else {
14031411 try list.appendSlice(sl);
......@@ -1408,7 +1416,7 @@ fn percentEncodeScalarML(list: *ManyArrayList(15, u8), n: usize, cp: []const u8,
14081416 if (set(cp[0])) {
14091417 for (cp) |b| {
14101418 try list.appendSlice(n, &.{'%'});
1411 try list.print(n, "{X:0<2}", .{b});
1419 try list.print(n, "{X:0>2}", .{b});
14121420 }
14131421 } else {
14141422 try list.appendSlice(n, &.{cp[0]});
......@@ -1420,7 +1428,7 @@ fn percentEncodeML(list: *ManyArrayList(15, u8), n: usize, input: []const u8, co
14201428 if (set(sl[0])) {
14211429 for (sl) |b| {
14221430 try list.appendSlice(n, &.{'%'});
1423 try list.print(n, "{X:0<2}", .{b});
1431 try list.print(n, "{X:0>2}", .{b});
14241432 }
14251433 } else {
14261434 try list.appendSlice(n, sl);
zig-out/test.zig+1-1
......@@ -27,7 +27,7 @@ pub fn parsePass(input: []const u8, base: ?[]const u8, href: []const u8, origin:
2727 try expect(u.port).toEqualString(port);
2828 _ = pathname;
2929 try expect(u.search).toEqualString(search);
30 _ = hash;
30 try expect(u.hash).toEqualString(hash);
3131}
3232
3333pub fn parseIDNAFail(comptime input: []const u8) !void {