diff --git a/lib/std/Uri.zig b/lib/std/Uri.zig index 198ab461ae..2228c78120 100644 --- a/lib/std/Uri.zig +++ b/lib/std/Uri.zig @@ -15,15 +15,15 @@ query: ?[]const u8, fragment: ?[]const u8, /// Applies URI encoding and replaces all reserved characters with their respective %XX code. -pub fn escapeString(allocator: std.mem.Allocator, input: []const u8) error{OutOfMemory}![]const u8 { +pub fn escapeString(allocator: std.mem.Allocator, input: []const u8) error{OutOfMemory}![]u8 { return escapeStringWithFn(allocator, input, isUnreserved); } -pub fn escapePath(allocator: std.mem.Allocator, input: []const u8) error{OutOfMemory}![]const u8 { +pub fn escapePath(allocator: std.mem.Allocator, input: []const u8) error{OutOfMemory}![]u8 { return escapeStringWithFn(allocator, input, isPathChar); } -pub fn escapeQuery(allocator: std.mem.Allocator, input: []const u8) error{OutOfMemory}![]const u8 { +pub fn escapeQuery(allocator: std.mem.Allocator, input: []const u8) error{OutOfMemory}![]u8 { return escapeStringWithFn(allocator, input, isQueryChar); } @@ -39,7 +39,7 @@ pub fn writeEscapedQuery(writer: anytype, input: []const u8) !void { return writeEscapedStringWithFn(writer, input, isQueryChar); } -pub fn escapeStringWithFn(allocator: std.mem.Allocator, input: []const u8, comptime keepUnescaped: fn (c: u8) bool) std.mem.Allocator.Error![]const u8 { +pub fn escapeStringWithFn(allocator: std.mem.Allocator, input: []const u8, comptime keepUnescaped: fn (c: u8) bool) std.mem.Allocator.Error![]u8 { var outsize: usize = 0; for (input) |c| { outsize += if (keepUnescaped(c)) @as(usize, 1) else 3; @@ -76,7 +76,7 @@ pub fn writeEscapedStringWithFn(writer: anytype, input: []const u8, comptime kee /// Parses a URI string and unescapes all %XX where XX is a valid hex number. Otherwise, verbatim copies /// them to the output. -pub fn unescapeString(allocator: std.mem.Allocator, input: []const u8) error{OutOfMemory}![]const u8 { +pub fn unescapeString(allocator: std.mem.Allocator, input: []const u8) error{OutOfMemory}![]u8 { var outsize: usize = 0; var inptr: usize = 0; while (inptr < input.len) {