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