curl / Mailing Lists / curl-users / Single Mail


Re: URL parsing for the command line tool?

From: David Niklas <>
Date: Wed, 15 Aug 2018 19:48:47 -0400

On Thu, 9 Aug 2018 15:57:32 +0200 (CEST)
Daniel Stenberg <> wrote:
> 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? Would you like curl to help your scripts
> or shells with in this regard?

if(( want_shell || want_script ) && IN_LATEST_COOL_CURL_VERSION)
  printf "Yes.\n\n"


> Extract the different parts from a URL? Maybe like this?
> in=""
> curl --url-input $in --url-out "%{host} %{path}\n"

Or like this:
export base="" # Base url.
export in2="download.html" # New part. Notice that the / is missing.
export in3="#Win64" # Something I added.

curl --append-urls $base $in2 $in3


curl --base-url $base $in2 $in3

> Maybe change parts of a URL and output the new version?
> curl --url-input $in --url-replace "" --url-out
> "%{url}\n"

Please try something more real world (even contrived). Why would
you want to change hosts? Your example makes no sense to me.

> 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"

export in1="../download.html"

for i in DragonFlyBSD FreeBSD NetBSD; do
  curl --base-url $base --output-url - $in1 "#" $i | ./

As an award for your work on curl I award you, the extra
large virtual happy face.

<@ @>

Sorry, I don't have anything more exiting...

Received on 2018-08-16