Discussion:
URL parsing for the command line tool?
(too old to reply)
Daniel Stenberg
2018-08-09 13:57:32 UTC
Permalink
Raw Message
Hi,

In a future libcurl release, there is going to be a URL parsing/handling API
[1] added. It can parse URLs, allow access to parts of the URL, setting or
updating specific parts and can "merge" a relative URL onto an absolute one.

Do you think the command line tool would benefit from offering these services
somehow? If so, how? What you like curl to help your scripts or shells with in
this regard?

Extract the different parts from a URL? Maybe like this?

in="https://example.com/index.html"
curl --url-input $in --url-out "%{host} %{path}\n"

Maybe change parts of a URL and output the new version?

curl --url-input $in --url-replace "host=example.org" --url-out "%{url}\n"

Perhaps applying a relative path onto an absolute URL and show the resulting
path part?

curl --url-input $in --url-new "../index?nooo" --url-out "%{path}\n"

I'm just brain-storming here.

[1] = https://github.com/curl/curl/wiki/URL-API
--
/ daniel.haxx.se
-----------------------------------------------------------
Unsubscribe: https://cool.haxx.se/list/listinfo/curl-users
Loading...