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