authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2026-01-22 18:56:08 -08:00
committergravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2026-01-22 18:56:08 -08:00
log2d1d8f7da877c6d71a30820361d38949164de1fc
tree1739cb89b4b25ab3a3dc56ffa156c97302aaa15d
parenta8eff70a99f05c0837b60b138c395b0f6d4000ff

populate search field


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

generate.ts+1-1
......@@ -56,7 +56,7 @@ pub fn parsePass(input: []const u8, base: ?[]const u8, href: []const u8, origin:
5656 _ = hostname;
5757 try expect(u.port).toEqualString(port);
5858 _ = pathname;
59 _ = search;
59 try expect(u.search).toEqualString(search);
6060 _ = hash;
6161}
6262
url.zig+7
......@@ -11,6 +11,7 @@ pub const URL = struct {
1111 username: []const u8,
1212 password: []const u8,
1313 port: []const u8,
14 search: []const u8,
1415
1516 pub const HostKind = enum {
1617 name,
......@@ -248,6 +249,7 @@ pub const URL = struct {
248249 if (c == '?') {
249250 href.clear(12);
250251 state = .query;
252 try href.appendSlice(11, &.{c});
251253 }
252254 // 3. Otherwise, if c is U+0023 (#), set url’s fragment to the empty string and state to fragment state.
253255 else if (c == '#') {
......@@ -484,6 +486,7 @@ pub const URL = struct {
484486 if (c == '?') {
485487 href.clear(12);
486488 state = .query;
489 try href.appendSlice(11, &.{c});
487490 }
488491 // 3. Otherwise, if c is U+0023 (#), set url’s fragment to the empty string and state to fragment state.
489492 else if (c == '#') {
......@@ -603,6 +606,7 @@ pub const URL = struct {
603606 else if (state_override == null and c == '?') {
604607 href.clear(12);
605608 state = .query;
609 try href.appendSlice(11, &.{c});
606610 }
607611 // 3. Otherwise, if state override is not given and c is U+0023 (#), set url’s fragment to the empty string and state to fragment state.
608612 else if (state_override == null and c == '#') {
......@@ -661,6 +665,7 @@ pub const URL = struct {
661665 if (c == '?') {
662666 href.clear(12);
663667 state = .query;
668 try href.appendSlice(11, &.{c});
664669 }
665670 // 7. If c is U+0023 (#), then set url’s fragment to the empty string and state to fragment state.
666671 if (c == '#') {
......@@ -689,6 +694,7 @@ pub const URL = struct {
689694 if (c == '?') {
690695 href.clear(12);
691696 state = .query;
697 try href.appendSlice(11, &.{c});
692698 }
693699 // 2. Otherwise, if c is U+0023 (#), then set url’s fragment to the empty string and state to fragment state.
694700 else if (c == '#') {
......@@ -785,6 +791,7 @@ pub const URL = struct {
785791 .username = _href[extras.sum(usize, href.lengths[0..2])..][0..href.lengths[3]],
786792 .password = _href[extras.sum(usize, href.lengths[0..4])..][0..href.lengths[5]],
787793 .port = _href[extras.sum(usize, href.lengths[0..8])..][0..href.lengths[9]],
794 .search = if (href.lengths[12] == 0) "" else _href[extras.sum(usize, href.lengths[0..11])..][0..extras.sum(usize, href.lengths[11..][0..2])],
788795 };
789796 return url;
790797 }
zig-out/test.zig+1-1
......@@ -26,7 +26,7 @@ pub fn parsePass(input: []const u8, base: ?[]const u8, href: []const u8, origin:
2626 _ = hostname;
2727 try expect(u.port).toEqualString(port);
2828 _ = pathname;
29 _ = search;
29 try expect(u.search).toEqualString(search);
3030 _ = hash;
3131}
3232