| author | |
| committer | |
| log | 7bd9b75b2cc7ca58cfcd543ad912790c6c8678eb |
| tree | f68932f4058a5868873e9a3ac45313ec64b55163 |
| parent | 8dbaebfd79b25b8f59072dae69122bb9d05e2550 |
3 files changed, 10 insertions(+), 7 deletions(-)
generate.ts+2-2| ... | ... | @@ -52,7 +52,7 @@ pub fn parsePass(input: []const u8, base: ?[]const u8, href: []const u8, origin: |
| 52 | 52 | try expect(u.password).toEqualString(password); |
| 53 | 53 | try expect(u.hostname).toEqualString(hostname); |
| 54 | 54 | try expect(u.port).toEqualString(port); |
| 55 | _ = host; | |
| 55 | try expect(u.host).toEqualString(host); | |
| 56 | 56 | _ = origin; |
| 57 | 57 | _ = pathname; |
| 58 | 58 | try expect(u.search).toEqualString(search); |
| ... | ... | @@ -75,7 +75,7 @@ pub fn parseIDNAPass(comptime input: []const u8, comptime output: []const u8) !v |
| 75 | 75 | const u = try url.URL.parse(allocator, "https://" ++ input ++ "/x", null); |
| 76 | 76 | defer allocator.free(u.href); |
| 77 | 77 | try expect(u.hostname).toEqualString(output); |
| 78 | // assert_equals(url.host, idnaTest.output); | |
| 78 | try expect(u.host).toEqualString(output); | |
| 79 | 79 | // assert_equals(url.pathname, "/x"); |
| 80 | 80 | // assert_equals(url.href, 'https://{idnaTest.output}/x'); |
| 81 | 81 | } |
url.zig+6-3| ... | ... | @@ -13,6 +13,7 @@ pub const URL = struct { |
| 13 | 13 | hostname: []const u8, |
| 14 | 14 | hostname_kind: HostKind = .name, |
| 15 | 15 | port: []const u8, |
| 16 | host: []const u8, | |
| 16 | 17 | search: []const u8, |
| 17 | 18 | hash: []const u8, |
| 18 | 19 | |
| ... | ... | @@ -399,6 +400,7 @@ pub const URL = struct { |
| 399 | 400 | hostname_kind = h; |
| 400 | 401 | buffer.clearRetainingCapacity(); |
| 401 | 402 | state = .port; |
| 403 | try href.set(8, ":"); | |
| 402 | 404 | } |
| 403 | 405 | // 3. Otherwise, if one of the following is true: |
| 404 | 406 | // - c is the EOF code point, U+002F (/), U+003F (?), or U+0023 (#) |
| ... | ... | @@ -800,11 +802,12 @@ pub const URL = struct { |
| 800 | 802 | const url: URL = .{ |
| 801 | 803 | .href = _href, |
| 802 | 804 | .protocol = _href[0..extras.sum(usize, href.lengths[0..2])], |
| 803 | .username = _href[extras.sum(usize, href.lengths[0..2])..][0..href.lengths[3]], | |
| 804 | .password = _href[extras.sum(usize, href.lengths[0..4])..][0..href.lengths[5]], | |
| 805 | .username = _href[extras.sum(usize, href.lengths[0..3])..][0..href.lengths[3]], | |
| 806 | .password = _href[extras.sum(usize, href.lengths[0..5])..][0..href.lengths[5]], | |
| 805 | 807 | .hostname = _href[extras.sum(usize, href.lengths[0..7])..][0..href.lengths[7]], |
| 806 | 808 | .hostname_kind = hostname_kind, |
| 807 | .port = _href[extras.sum(usize, href.lengths[0..8])..][0..href.lengths[9]], | |
| 809 | .port = _href[extras.sum(usize, href.lengths[0..9])..][0..href.lengths[9]], | |
| 810 | .host = _href[extras.sum(usize, href.lengths[0..7])..][0..extras.sum(usize, href.lengths[7..][0..if (href.lengths[9] == 0) 1 else 3])], | |
| 808 | 811 | .search = if (href.lengths[12] == 0) "" else _href[extras.sum(usize, href.lengths[0..11])..][0..extras.sum(usize, href.lengths[11..][0..2])], |
| 809 | 812 | .hash = if (href.lengths[14] == 0) "" else _href[extras.sum(usize, href.lengths[0..13])..][0..extras.sum(usize, href.lengths[13..][0..2])], |
| 810 | 813 | }; |
zig-out/test.zig+2-2| ... | ... | @@ -22,7 +22,7 @@ pub fn parsePass(input: []const u8, base: ?[]const u8, href: []const u8, origin: |
| 22 | 22 | try expect(u.password).toEqualString(password); |
| 23 | 23 | try expect(u.hostname).toEqualString(hostname); |
| 24 | 24 | try expect(u.port).toEqualString(port); |
| 25 | _ = host; | |
| 25 | try expect(u.host).toEqualString(host); | |
| 26 | 26 | _ = origin; |
| 27 | 27 | _ = pathname; |
| 28 | 28 | try expect(u.search).toEqualString(search); |
| ... | ... | @@ -45,7 +45,7 @@ pub fn parseIDNAPass(comptime input: []const u8, comptime output: []const u8) !v |
| 45 | 45 | const u = try url.URL.parse(allocator, "https://" ++ input ++ "/x", null); |
| 46 | 46 | defer allocator.free(u.href); |
| 47 | 47 | try expect(u.hostname).toEqualString(output); |
| 48 | // assert_equals(url.host, idnaTest.output); | |
| 48 | try expect(u.host).toEqualString(output); | |
| 49 | 49 | // assert_equals(url.pathname, "/x"); |
| 50 | 50 | // assert_equals(url.href, 'https://{idnaTest.output}/x'); |
| 51 | 51 | } |