-
Notifications
You must be signed in to change notification settings - Fork 103
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Please support zero-sized fragment and query #226
Comments
I think this is a limitation of libcurl's urlapi |
From the manual for curl_url_get:
|
I was mainly referring to it normalising
libcurl always normalises empty query/fragment as no query/fragment; and it does not provide a way to distinguish empty fragment from no fragment. #include <curl/curl.h>
int main(int const argc, char const *const argv[])
{
if (argc != 2)
return 1;
CURLU *const uh = curl_url();
curl_url_set(uh, CURLUPART_URL, argv[1],
CURLU_NON_SUPPORT_SCHEME|
CURLU_GUESS_SCHEME|
CURLU_URLENCODE);
char *url;
curl_url_get(uh, CURLUPART_URL, &url, CURLU_DEFAULT_PORT);
char *query;
curl_url_get(uh, CURLUPART_QUERY, &query, CURLU_DEFAULT_PORT);
char *frag;
curl_url_get(uh, CURLUPART_FRAGMENT, &frag, CURLU_DEFAULT_PORT);
printf("in:\t%s\n"
"out:\t%s\n"
"query:\t%s\n"
"frag:\t%s\n",
argv[1], url, query ? query : "NULL", frag ? frag : "NULL");
curl_free(url);
curl_free(query);
curl_free(frag);
curl_url_cleanup(uh);
return 0;
} |
Yes, I was hoping that it could be reflected in trurl as well. (and Thank you for providing also the full demo code :) |
See curl/curl#13396 |
With libcurl supporting empty queries and fragments now, how do you think we should enable this in trurl? |
Probably would be useful to have and have --get {component} return nothing if not present and the empty line if present. But those would be breaking changes. |
I think we are free to do breaking changes if we want, at least before an official version one. I think the bigger problem is that they would work differently depending on what the underlying libcurl in use supports... |
another (clunky) solution may be a new flag or something clever with the the modifiers in the get brackets |
I figure we might need to do some other syntax extension/change for that. Maybe
Of course, this would only work for query and fragment. Maybe path? |
There is also the shell problem: how would a script differentiate between a blank query and a non-existing one?
vs
What is the expected output for a zero length query vs a non-existing one? |
I guess the latter has to report an error somehow, maybe adding a |
#336 at least partly satisfies this. |
@lu-zero does this satisfy your use case or is there anything more you want/need to differentiate empty/missing components for? |
I think it is enough, thank you :) |
scheme://host/path/#
andscheme://host/path/
are different and so isscheme://host/path/?
.It would be nice if
--get
lets you differentiate them and and--set
lets you produce them.The text was updated successfully, but these errors were encountered: