curl / Mailing Lists / curl-library / Single Mail

curl-library

Re: a URL API ?

From: Daniel Stenberg via curl-library <curl-library_at_cool.haxx.se>
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?

-- 
  / daniel.haxx.se
-------------------------------------------------------------------
Unsubscribe: https://cool.haxx.se/list/listinfo/curl-library
Etiquette:   https://curl.haxx.se/mail/etiquette.html
Received on 2018-08-12