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