curl / Mailing Lists / curl-library / Single Mail


Re: a URL API ?

From: Daniel Stenberg via curl-library <>
Date: Sun, 12 Aug 2018 18:45:27 +0200 (CEST)

On Sun, 12 Aug 2018, Dan Fandrich via curl-library wrote:

> I'm curious whether the API can be used to canonicalize a URL, i.e., URL
> decode parts that can be decoded without semantic difference but
> canonicalize those parts that the specs say must be encoded.

I think it should be possible

> The idea would be that the output of canonicalization would be the same for
> every version of a URL passed in. I'm guessing that url_url_get(h,
> CURLUPART_URL, &lost, CURLU_URLDECODE); would get you half way there, except
> that it might not encode parts that have to be encoded. Is there another
> way I'm missing?

The current code for the API doesn't offer URL decoding at all when you ask
for the full URL - since a returned URL is still supposed to be a URL so it
can't really be "decoded" then. We can of course document that bit to mean
"canonicalization" when used in combination with getting the URL.

Canonicalization can probably be done by always URL decoding *and* URL
encoding each individual part before they're put together to the end result...
Wouldn't that work?

Received on 2018-08-12