#define build_path(url, first, ...) build_path_((url), (first), __VA_ARGS__, NULL) static Noh_String build_path_(bool url, Noh_String_View *first, ...) { va_list args; Noh_String_View *elem_ = first; va_start(args, first); bool start = true; Noh_String result = {0}; if (url || noh_sv_starts_with(*first, noh_sv_from_cstr("/"))) noh_string_append_cstr(&result, "/"); while (elem_ != NULL) { Noh_String_View elem = *elem_; while (elem.count > 0) { Noh_String_View component = noh_sv_chop_by_delim(&elem, '/'); if (noh_sv_eq(component, sv(".."))) continue; if (component.count > 0) { if (start) start = false; else noh_string_append_cstr(&result, "/"); noh_string_append_sv(&result, component); } } elem_ = va_arg(args, Noh_String_View *); } va_end(args); return result; }