| ... | ... | @@ -5,7 +5,7 @@ const std = @import("std.zig"); |
| 5 | 5 | const testing = std.testing; |
| 6 | 6 | const Uri = @This(); |
| 7 | 7 | const Allocator = std.mem.Allocator; |
| 8 | | const Writer = std.io.Writer; |
| 8 | const Writer = std.Io.Writer; |
| 9 | 9 | |
| 10 | 10 | scheme: []const u8, |
| 11 | 11 | user: ?Component = null, |
| ... | ... | @@ -70,14 +70,11 @@ pub const Component = union(enum) { |
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | /// Allocates the result with `arena` only if needed, so the result should not be freed. |
| 73 | | pub fn toRawMaybeAlloc( |
| 74 | | component: Component, |
| 75 | | arena: Allocator, |
| 76 | | ) Allocator.Error![]const u8 { |
| 73 | pub fn toRawMaybeAlloc(component: Component, arena: Allocator) Allocator.Error![]const u8 { |
| 77 | 74 | return switch (component) { |
| 78 | 75 | .raw => |raw| raw, |
| 79 | 76 | .percent_encoded => |percent_encoded| if (std.mem.indexOfScalar(u8, percent_encoded, '%')) |_| |
| 80 | | try std.fmt.allocPrint(arena, "{fraw}", .{component}) |
| 77 | try std.fmt.allocPrint(arena, "{f}", .{std.fmt.alt(component, .formatRaw)}) |
| 81 | 78 | else |
| 82 | 79 | percent_encoded, |
| 83 | 80 | }; |