395 ucx_buffer_puts(href, random_name); |
395 ucx_buffer_puts(href, random_name); |
396 free(random_name); |
396 free(random_name); |
397 } else { |
397 } else { |
398 // path is not URL encoded, so we have to do this here |
398 // path is not URL encoded, so we have to do this here |
399 scstr_t resname = scstr(util_resource_name(path)); |
399 scstr_t resname = scstr(util_resource_name(path)); |
400 char *esc = curl_easy_escape(sn->handle, |
400 // the name of collections ends with |
401 resname.ptr, resname.length); |
401 // a trailing slash, which MUST NOT be encoded |
402 ucx_buffer_write(esc, 1, strlen(esc), href); |
402 if(resname.ptr[resname.length-1] == '/') { |
403 curl_free(esc); |
403 char *esc = curl_easy_escape(sn->handle, |
|
404 resname.ptr, resname.length-1); |
|
405 ucx_buffer_write(esc, 1, strlen(esc), href); |
|
406 ucx_buffer_putc(href, '/'); |
|
407 curl_free(esc); |
|
408 } else { |
|
409 char *esc = curl_easy_escape(sn->handle, |
|
410 resname.ptr, resname.length); |
|
411 ucx_buffer_write(esc, 1, strlen(esc), href); |
|
412 curl_free(esc); |
|
413 } |
404 } |
414 } |
405 } |
415 } |
406 |
416 |
407 // cleanup |
417 // cleanup |
408 free(elm.ptr); |
418 free(elm.ptr); |