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:...@@ -56,7 +56,7 @@ pub fn parsePass(input: []const u8, base: ?[]const u8, href: []const u8, origin:
56 _ = hostname;56 _ = hostname;
57 try expect(u.port).toEqualString(port);57 try expect(u.port).toEqualString(port);
58 _ = pathname;58 _ = pathname;
59 _ = search;59 try expect(u.search).toEqualString(search);
60 _ = hash;60 _ = hash;
61}61}
6262
url.zig+7
...@@ -11,6 +11,7 @@ pub const URL = struct {...@@ -11,6 +11,7 @@ pub const URL = struct {
11 username: []const u8,11 username: []const u8,
12 password: []const u8,12 password: []const u8,
13 port: []const u8,13 port: []const u8,
14 search: []const u8,
1415
15 pub const HostKind = enum {16 pub const HostKind = enum {
16 name,17 name,
...@@ -248,6 +249,7 @@ pub const URL = struct {...@@ -248,6 +249,7 @@ pub const URL = struct {
248 if (c == '?') {249 if (c == '?') {
249 href.clear(12);250 href.clear(12);
250 state = .query;251 state = .query;
252 try href.appendSlice(11, &.{c});
251 }253 }
252 // 3. Otherwise, if c is U+0023 (#), set url’s fragment to the empty string and state to fragment state.254 // 3. Otherwise, if c is U+0023 (#), set url’s fragment to the empty string and state to fragment state.
253 else if (c == '#') {255 else if (c == '#') {
...@@ -484,6 +486,7 @@ pub const URL = struct {...@@ -484,6 +486,7 @@ pub const URL = struct {
484 if (c == '?') {486 if (c == '?') {
485 href.clear(12);487 href.clear(12);
486 state = .query;488 state = .query;
489 try href.appendSlice(11, &.{c});
487 }490 }
488 // 3. Otherwise, if c is U+0023 (#), set url’s fragment to the empty string and state to fragment state.491 // 3. Otherwise, if c is U+0023 (#), set url’s fragment to the empty string and state to fragment state.
489 else if (c == '#') {492 else if (c == '#') {
...@@ -603,6 +606,7 @@ pub const URL = struct {...@@ -603,6 +606,7 @@ pub const URL = struct {
603 else if (state_override == null and c == '?') {606 else if (state_override == null and c == '?') {
604 href.clear(12);607 href.clear(12);
605 state = .query;608 state = .query;
609 try href.appendSlice(11, &.{c});
606 }610 }
607 // 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.611 // 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.
608 else if (state_override == null and c == '#') {612 else if (state_override == null and c == '#') {
...@@ -661,6 +665,7 @@ pub const URL = struct {...@@ -661,6 +665,7 @@ pub const URL = struct {
661 if (c == '?') {665 if (c == '?') {
662 href.clear(12);666 href.clear(12);
663 state = .query;667 state = .query;
668 try href.appendSlice(11, &.{c});
664 }669 }
665 // 7. If c is U+0023 (#), then set url’s fragment to the empty string and state to fragment state.670 // 7. If c is U+0023 (#), then set url’s fragment to the empty string and state to fragment state.
666 if (c == '#') {671 if (c == '#') {
...@@ -689,6 +694,7 @@ pub const URL = struct {...@@ -689,6 +694,7 @@ pub const URL = struct {
689 if (c == '?') {694 if (c == '?') {
690 href.clear(12);695 href.clear(12);
691 state = .query;696 state = .query;
697 try href.appendSlice(11, &.{c});
692 }698 }
693 // 2. Otherwise, if c is U+0023 (#), then set url’s fragment to the empty string and state to fragment state.699 // 2. Otherwise, if c is U+0023 (#), then set url’s fragment to the empty string and state to fragment state.
694 else if (c == '#') {700 else if (c == '#') {
...@@ -785,6 +791,7 @@ pub const URL = struct {...@@ -785,6 +791,7 @@ pub const URL = struct {
785 .username = _href[extras.sum(usize, href.lengths[0..2])..][0..href.lengths[3]],791 .username = _href[extras.sum(usize, href.lengths[0..2])..][0..href.lengths[3]],
786 .password = _href[extras.sum(usize, href.lengths[0..4])..][0..href.lengths[5]],792 .password = _href[extras.sum(usize, href.lengths[0..4])..][0..href.lengths[5]],
787 .port = _href[extras.sum(usize, href.lengths[0..8])..][0..href.lengths[9]],793 .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])],
788 };795 };
789 return url;796 return url;
790 }797 }
zig-out/test.zig+1-1
...@@ -26,7 +26,7 @@ pub fn parsePass(input: []const u8, base: ?[]const u8, href: []const u8, origin:...@@ -26,7 +26,7 @@ pub fn parsePass(input: []const u8, base: ?[]const u8, href: []const u8, origin:
26 _ = hostname;26 _ = hostname;
27 try expect(u.port).toEqualString(port);27 try expect(u.port).toEqualString(port);
28 _ = pathname;28 _ = pathname;
29 _ = search;29 try expect(u.search).toEqualString(search);
30 _ = hash;30 _ = hash;
31}31}
3232