mirror of
https://github.com/curl/curl.git
synced 2026-08-12 02:10:52 +03:00
parent
58023ba522
commit
56129718b8
1 changed files with 8 additions and 20 deletions
|
|
@ -165,23 +165,15 @@ CURLcode ipfs_url_rewrite(CURLU *uh, const char *protocol, char **url,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* get gateway parts */
|
/* get gateway parts */
|
||||||
if(curl_url_get(gatewayurl, CURLUPART_HOST,
|
if(curl_url_get(gatewayurl, CURLUPART_HOST, &gwhost, CURLU_URLDECODE) ||
|
||||||
&gwhost, CURLU_URLDECODE)) {
|
curl_url_get(gatewayurl, CURLUPART_SCHEME, &gwscheme, CURLU_URLDECODE) ||
|
||||||
goto clean;
|
curl_url_get(gatewayurl, CURLUPART_PORT, &gwport, CURLU_URLDECODE) ||
|
||||||
}
|
curl_url_get(gatewayurl, CURLUPART_PATH, &gwpath, CURLU_URLDECODE))
|
||||||
|
|
||||||
if(curl_url_get(gatewayurl, CURLUPART_SCHEME,
|
|
||||||
&gwscheme, CURLU_URLDECODE)) {
|
|
||||||
goto clean;
|
|
||||||
}
|
|
||||||
|
|
||||||
curl_url_get(gatewayurl, CURLUPART_PORT, &gwport, CURLU_URLDECODE);
|
|
||||||
|
|
||||||
if(curl_url_get(gatewayurl, CURLUPART_PATH, &gwpath, CURLU_URLDECODE))
|
|
||||||
goto clean;
|
goto clean;
|
||||||
|
|
||||||
/* get the path from user input */
|
/* get the path from user input */
|
||||||
curl_url_get(uh, CURLUPART_PATH, &inputpath, CURLU_URLDECODE);
|
if(curl_url_get(uh, CURLUPART_PATH, &inputpath, CURLU_URLDECODE))
|
||||||
|
goto clean;
|
||||||
/* inputpath might be NULL or a valid pointer now */
|
/* inputpath might be NULL or a valid pointer now */
|
||||||
|
|
||||||
/* set gateway parts in input url */
|
/* set gateway parts in input url */
|
||||||
|
|
@ -198,13 +190,9 @@ CURLcode ipfs_url_rewrite(CURLU *uh, const char *protocol, char **url,
|
||||||
has_trailing_slash(gwpath) ? "" : "/",
|
has_trailing_slash(gwpath) ? "" : "/",
|
||||||
protocol, cid,
|
protocol, cid,
|
||||||
inputpath ? inputpath : "");
|
inputpath ? inputpath : "");
|
||||||
if(!pathbuffer) {
|
if(!pathbuffer ||
|
||||||
|
curl_url_set(uh, CURLUPART_PATH, pathbuffer, CURLU_URLENCODE))
|
||||||
goto clean;
|
goto clean;
|
||||||
}
|
|
||||||
|
|
||||||
if(curl_url_set(uh, CURLUPART_PATH, pathbuffer, CURLU_URLENCODE)) {
|
|
||||||
goto clean;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Free whatever it has now, rewriting is next */
|
/* Free whatever it has now, rewriting is next */
|
||||||
tool_safefree(*url);
|
tool_safefree(*url);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue