Implement userctl user registering
This commit is contained in:
27
src/path.c
Normal file
27
src/path.c
Normal file
@@ -0,0 +1,27 @@
|
||||
#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_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;
|
||||
}
|
||||
Reference in New Issue
Block a user