urlapi: add CURLU_GET_EMPTY for empty queries and fragments

By default the API inhibits empty queries and fragments extracted.
Unless this new flag is set.

This also makes the behavior more consistent: without it set, zero
length queries and fragments are considered not present in the URL. With
the flag set, they are returned as a zero length strings if they were in
fact present in the URL.

This applies when extracting the individual query and fragment
components and for the full URL.

Closes #13396
This commit is contained in:
Daniel Stenberg 2024-04-17 11:39:25 +02:00
parent 5379dbc248
commit 3eac21d86b
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
6 changed files with 77 additions and 10 deletions

View file

@ -113,6 +113,18 @@ punycode.
(Added in curl 8.3.0)
## CURLU_GET_EMPTY
When this flag is used in curl_url_get(), it makes the function return empty
query and fragments parts or when used in the full URL. By default, libcurl
otherwise considers empty parts non-existing.
An empty query part is one where this is nothing following the question mark
(before the possible fragment). An empty fragments part is one where there is
nothing following the hash sign.
(Added in curl 8.8.0)
# PARTS
## CURLUPART_URL

View file

@ -1064,6 +1064,7 @@ CURLU_APPENDQUERY 7.62.0
CURLU_DEFAULT_PORT 7.62.0
CURLU_DEFAULT_SCHEME 7.62.0
CURLU_DISALLOW_USER 7.62.0
CURLU_GET_EMPTY 8.8.0
CURLU_GUESS_SCHEME 7.62.0
CURLU_NO_AUTHORITY 7.67.0
CURLU_NO_DEFAULT_PORT 7.62.0