Zig 0.17.0-dev (Split by item)

This is an example of documentation generated by ZigDoc, an alternative to Zig's built-in Auto Doc feature. See also examples in other modes/formats. The project being documented here (as the example) is the Zig library itself.

merge_paths

5.2.3. Merge Paths

Uri.merge_paths
fn merge_paths(base: Component, new: []u8, aux_buf: *[]u8) error

File

lib/std/Uri.zig:474

Code

fn 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.lastIndexOfScalar(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;
}