--- a/test/utils.c Wed Jan 07 22:31:05 2026 +0100 +++ b/test/utils.c Fri Jan 09 14:52:34 2026 +0100 @@ -55,6 +55,79 @@ } } +CX_TEST(test_util_url_base) { + CX_TEST_DO { + char *path = util_url_base("http://example.com/basepath/123/"); + CX_TEST_ASSERT(path && !strcmp(path, "http://example.com/")); + free(path); + + path = util_url_base("http://example.com/"); + CX_TEST_ASSERT(path && !strcmp(path, "http://example.com/")); + free(path); + + path = util_url_base("https://example.com/basepath/123/"); + CX_TEST_ASSERT(path && !strcmp(path, "https://example.com/")); + free(path); + + path = util_url_base("https://example.com/"); + CX_TEST_ASSERT(path && !strcmp(path, "https://example.com/")); + free(path); + + path = util_url_base("http://example.com:8080/basepath/123/"); + CX_TEST_ASSERT(path && !strcmp(path, "http://example.com:8080/")); + free(path); + + path = util_url_base("http://user@example.com/"); + CX_TEST_ASSERT(path && !strcmp(path, "http://user@example.com/")); + free(path); + + //path = util_url_base("http://example.com"); + //CX_TEST_ASSERT(path && !strcmp(path, "http://example.com/")); + //free(path); + } +} + +CX_TEST(test_util_concat_path) { + CX_TEST_DO { + char *str = util_concat_path("", ""); + CX_TEST_ASSERT(str); + CX_TEST_ASSERT(!strcmp(str, "/")); + free(str); + + str = util_concat_path("/test", "abc"); + CX_TEST_ASSERT(str); + CX_TEST_ASSERT(!cx_strcmp(str, "/test/abc")); + free(str); + + str = util_concat_path("/test/", "abc"); + CX_TEST_ASSERT(str); + CX_TEST_ASSERT(!cx_strcmp(str, "/test/abc")); + free(str); + + str = util_concat_path("/test", "/abc"); + CX_TEST_ASSERT(str); + CX_TEST_ASSERT(!cx_strcmp(str, "/test/abc")); + free(str); + + str = util_concat_path("/test/", "/abc"); + CX_TEST_ASSERT(str); + CX_TEST_ASSERT(!cx_strcmp(str, "/test/abc")); + free(str); + + str = util_concat_path("/test/123/long", "/dir1/dir2/dir3"); + CX_TEST_ASSERT(str); + CX_TEST_ASSERT(!cx_strcmp(str, "/test/123/long/dir1/dir2/dir3")); + free(str); + + str = util_concat_path("relative", "path"); + CX_TEST_ASSERT(str); + CX_TEST_ASSERT(!cx_strcmp(str, "relative/path")); + free(str); + } +} + + + CX_TEST(test_util_path_isrelated) { CX_TEST_DO { CX_TEST_ASSERT(util_path_isrelated("/", "/"));