| ... | ... | @@ -12,6 +12,7 @@ pub const URL = struct { |
| 12 | 12 | password: []const u8, |
| 13 | 13 | port: []const u8, |
| 14 | 14 | search: []const u8, |
| 15 | hash: []const u8, |
| 15 | 16 | |
| 16 | 17 | pub const HostKind = enum { |
| 17 | 18 | name, |
| ... | ... | @@ -255,6 +256,7 @@ pub const URL = struct { |
| 255 | 256 | else if (c == '#') { |
| 256 | 257 | href.clear(14); |
| 257 | 258 | state = .fragment; |
| 259 | try href.appendSlice(13, &.{c}); |
| 258 | 260 | } |
| 259 | 261 | // 4. Otherwise, if c is not the EOF code point: |
| 260 | 262 | else if (i < length) { |
| ... | ... | @@ -492,6 +494,7 @@ pub const URL = struct { |
| 492 | 494 | else if (c == '#') { |
| 493 | 495 | href.clear(14); |
| 494 | 496 | state = .fragment; |
| 497 | try href.appendSlice(13, &.{c}); |
| 495 | 498 | } |
| 496 | 499 | // 4. Otherwise, if c is not the EOF code point: |
| 497 | 500 | else if (i < length) { |
| ... | ... | @@ -612,6 +615,7 @@ pub const URL = struct { |
| 612 | 615 | else if (state_override == null and c == '#') { |
| 613 | 616 | href.clear(14); |
| 614 | 617 | state = .fragment; |
| 618 | try href.appendSlice(13, &.{c}); |
| 615 | 619 | } |
| 616 | 620 | // 4. Otherwise, if c is not the EOF code point: |
| 617 | 621 | else if (i < length) { |
| ... | ... | @@ -671,6 +675,7 @@ pub const URL = struct { |
| 671 | 675 | if (c == '#') { |
| 672 | 676 | href.clear(14); |
| 673 | 677 | state = .fragment; |
| 678 | try href.appendSlice(13, &.{c}); |
| 674 | 679 | } |
| 675 | 680 | } |
| 676 | 681 | // 2. Otherwise, run these steps: |
| ... | ... | @@ -700,6 +705,7 @@ pub const URL = struct { |
| 700 | 705 | else if (c == '#') { |
| 701 | 706 | href.clear(14); |
| 702 | 707 | state = .fragment; |
| 708 | try href.appendSlice(13, &.{c}); |
| 703 | 709 | } |
| 704 | 710 | // 3. Otherwise, if c is U+0020 SPACE: |
| 705 | 711 | else if (c == ' ') { |
| ... | ... | @@ -747,6 +753,7 @@ pub const URL = struct { |
| 747 | 753 | if (c == '#') { |
| 748 | 754 | href.clear(14); |
| 749 | 755 | state = .fragment; |
| 756 | try href.appendSlice(13, &.{c}); |
| 750 | 757 | } |
| 751 | 758 | } |
| 752 | 759 | // 3. Otherwise, if c is not the EOF code point: |
| ... | ... | @@ -792,6 +799,7 @@ pub const URL = struct { |
| 792 | 799 | .password = _href[extras.sum(usize, href.lengths[0..4])..][0..href.lengths[5]], |
| 793 | 800 | .port = _href[extras.sum(usize, href.lengths[0..8])..][0..href.lengths[9]], |
| 794 | 801 | .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])], |
| 795 | 803 | }; |
| 796 | 804 | return url; |
| 797 | 805 | } |
| ... | ... | @@ -1385,7 +1393,7 @@ fn percentEncodeScalarAL(list: *std.ArrayList(u8), cp: []const u8, comptime set: |
| 1385 | 1393 | if (set(cp[0])) { |
| 1386 | 1394 | for (cp) |b| { |
| 1387 | 1395 | try list.append('%'); |
| 1388 | | try list.writer().print("{X:0<2}", .{b}); |
| 1396 | try list.writer().print("{X:0>2}", .{b}); |
| 1389 | 1397 | } |
| 1390 | 1398 | } else { |
| 1391 | 1399 | try list.append(cp[0]); |
| ... | ... | @@ -1397,7 +1405,7 @@ fn percentEncodeAL(list: *std.ArrayList(u8), input: []const u8, comptime set: fn |
| 1397 | 1405 | if (set(sl[0])) { |
| 1398 | 1406 | for (sl) |b| { |
| 1399 | 1407 | try list.append('%'); |
| 1400 | | try list.writer().print("{X:0<2}", .{b}); |
| 1408 | try list.writer().print("{X:0>2}", .{b}); |
| 1401 | 1409 | } |
| 1402 | 1410 | } else { |
| 1403 | 1411 | try list.appendSlice(sl); |
| ... | ... | @@ -1408,7 +1416,7 @@ fn percentEncodeScalarML(list: *ManyArrayList(15, u8), n: usize, cp: []const u8, |
| 1408 | 1416 | if (set(cp[0])) { |
| 1409 | 1417 | for (cp) |b| { |
| 1410 | 1418 | try list.appendSlice(n, &.{'%'}); |
| 1411 | | try list.print(n, "{X:0<2}", .{b}); |
| 1419 | try list.print(n, "{X:0>2}", .{b}); |
| 1412 | 1420 | } |
| 1413 | 1421 | } else { |
| 1414 | 1422 | try list.appendSlice(n, &.{cp[0]}); |
| ... | ... | @@ -1420,7 +1428,7 @@ fn percentEncodeML(list: *ManyArrayList(15, u8), n: usize, input: []const u8, co |
| 1420 | 1428 | if (set(sl[0])) { |
| 1421 | 1429 | for (sl) |b| { |
| 1422 | 1430 | try list.appendSlice(n, &.{'%'}); |
| 1423 | | try list.print(n, "{X:0<2}", .{b}); |
| 1431 | try list.print(n, "{X:0>2}", .{b}); |
| 1424 | 1432 | } |
| 1425 | 1433 | } else { |
| 1426 | 1434 | try list.appendSlice(n, sl); |