Maintain case when making a URI from a file, make drive letter lowercase on windows
This commit is contained in:
parent
bb964a5aed
commit
9fc7d1f66e
12
src/uri.zig
12
src/uri.zig
@ -24,7 +24,17 @@ pub fn fromPath(allocator: *std.mem.Allocator, path: []const u8) ![]const u8 {
|
||||
try buf.append('%');
|
||||
try std.fmt.format(out_stream, "{X}", .{char});
|
||||
} else {
|
||||
try buf.append(std.ascii.toLower(char));
|
||||
try buf.append(char);
|
||||
}
|
||||
}
|
||||
|
||||
// On windows, we need to lowercase the drive name.
|
||||
if (std.builtin.os.tag == .windows) {
|
||||
if (buf.items.len > prefix.len + 1 and
|
||||
std.ascii.isAlpha(buf.items[prefix.len]) and
|
||||
std.mem.startsWith(u8, buf.items[prefix.len + 1 ..], "%3A"))
|
||||
{
|
||||
buf.items[prefix.len] = std.ascii.toLower(buf.items[prefix.len]);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user