fn merge_paths(base: Component, new: []u8, aux_buf: *[]u8) error base: Componentnew: []u8aux_buf: *[]u8474
475
476
477
478
479
480
481
482
483
484fn merge_paths(base: Component, new: []u8, aux_buf: *[]u8) error{NoSpaceLeft}!Component {
var aux: Writer = .fixed(aux_buf.*);
if (!base.isEmpty()) {
base.formatPath(&aux) catch return error.NoSpaceLeft;
aux.end = std.mem.findScalarLast(u8, aux.buffered(), '/') orelse return remove_dot_segments(new);
}
aux.print("/{s}", .{new}) catch return error.NoSpaceLeft;
const merged_path = remove_dot_segments(aux.buffered());
aux_buf.* = aux_buf.*[merged_path.percent_encoded.len..];
return merged_path;
}
5.2.3. Merge Paths