Add url_resolve_reference to translare relative references to absolute URLs

This commit is contained in:
2025-12-06 01:25:22 +01:00
parent 1d53c3d8ac
commit f5b0f3a142
3 changed files with 306 additions and 24 deletions
+9 -1
View File
@@ -310,6 +310,7 @@ static int run_test(cJSON *json)
}
int ret;
char tmp[1<<10];
char buf[1<<10];
URL parsed;
if (cJSON_IsNull(json_base)) {
@@ -335,6 +336,13 @@ static int run_test(cJSON *json)
}
assert(ret == 0);
ret = url_remove_white_space(src.ptr, src.len, tmp, (int) sizeof(tmp));
if (ret > (int) sizeof(tmp)) {
assert(0); // TODO
}
src.ptr = tmp;
src.len = ret;
ret = url_resolve_reference(src.ptr, src.len, NULL, &parsed_base, false, buf, (int) sizeof(buf));
if (ret >= (int) sizeof(buf)) {
test_printf("\n");
@@ -440,7 +448,7 @@ static char *load_file(char *path)
int main(void)
{
char *path = "data/urltestdata.json";
char *path = "wpt/urltestdata.json";
char *buf = load_file(path);
if (buf == NULL) {
fprintf(stderr, "Error: Couldn't open %s\n", path);