authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2025-08-01 16:52:58-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2025-08-01 16:52:58-07:00
logc5231a8fb4463f7087c6090c562531065a1869f9
tree8abc960d4fa92cf6a70d8be8e2823470c783c9fe
parent08efe0d598b43951321a9e651c0ff62825db6ee6

sync


1 files changed, 3 insertions(+), 6 deletions(-)

lib/std/Uri.zig+3-6
......@@ -5,7 +5,7 @@ const std = @import("std.zig");
55const testing = std.testing;
66const Uri = @This();
77const Allocator = std.mem.Allocator;
8const Writer = std.io.Writer;
8const Writer = std.Io.Writer;
99
1010scheme: []const u8,
1111user: ?Component = null,
......@@ -70,14 +70,11 @@ pub const Component = union(enum) {
7070 }
7171
7272 /// 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 {
7774 return switch (component) {
7875 .raw => |raw| raw,
7976 .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)})
8178 else
8279 percent_encoded,
8380 };