| ... | ... | @@ -11,6 +11,7 @@ pub const URL = struct { |
| 11 | 11 | username: []const u8, |
| 12 | 12 | password: []const u8, |
| 13 | 13 | port: []const u8, |
| 14 | search: []const u8, |
| 14 | 15 | |
| 15 | 16 | pub const HostKind = enum { |
| 16 | 17 | name, |
| ... | ... | @@ -248,6 +249,7 @@ pub const URL = struct { |
| 248 | 249 | if (c == '?') { |
| 249 | 250 | href.clear(12); |
| 250 | 251 | state = .query; |
| 252 | try href.appendSlice(11, &.{c}); |
| 251 | 253 | } |
| 252 | 254 | // 3. Otherwise, if c is U+0023 (#), set url’s fragment to the empty string and state to fragment state. |
| 253 | 255 | else if (c == '#') { |
| ... | ... | @@ -484,6 +486,7 @@ pub const URL = struct { |
| 484 | 486 | if (c == '?') { |
| 485 | 487 | href.clear(12); |
| 486 | 488 | state = .query; |
| 489 | try href.appendSlice(11, &.{c}); |
| 487 | 490 | } |
| 488 | 491 | // 3. Otherwise, if c is U+0023 (#), set url’s fragment to the empty string and state to fragment state. |
| 489 | 492 | else if (c == '#') { |
| ... | ... | @@ -603,6 +606,7 @@ pub const URL = struct { |
| 603 | 606 | else if (state_override == null and c == '?') { |
| 604 | 607 | href.clear(12); |
| 605 | 608 | state = .query; |
| 609 | try href.appendSlice(11, &.{c}); |
| 606 | 610 | } |
| 607 | 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 | 612 | else if (state_override == null and c == '#') { |
| ... | ... | @@ -661,6 +665,7 @@ pub const URL = struct { |
| 661 | 665 | if (c == '?') { |
| 662 | 666 | href.clear(12); |
| 663 | 667 | state = .query; |
| 668 | try href.appendSlice(11, &.{c}); |
| 664 | 669 | } |
| 665 | 670 | // 7. If c is U+0023 (#), then set url’s fragment to the empty string and state to fragment state. |
| 666 | 671 | if (c == '#') { |
| ... | ... | @@ -689,6 +694,7 @@ pub const URL = struct { |
| 689 | 694 | if (c == '?') { |
| 690 | 695 | href.clear(12); |
| 691 | 696 | state = .query; |
| 697 | try href.appendSlice(11, &.{c}); |
| 692 | 698 | } |
| 693 | 699 | // 2. Otherwise, if c is U+0023 (#), then set url’s fragment to the empty string and state to fragment state. |
| 694 | 700 | else if (c == '#') { |
| ... | ... | @@ -785,6 +791,7 @@ pub const URL = struct { |
| 785 | 791 | .username = _href[extras.sum(usize, href.lengths[0..2])..][0..href.lengths[3]], |
| 786 | 792 | .password = _href[extras.sum(usize, href.lengths[0..4])..][0..href.lengths[5]], |
| 787 | 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 | 796 | return url; |
| 790 | 797 | } |