NAME

url - format a URL according to a sprintf-like template

SYNOPSIS

# format as just the host
$ url '%H' http://www.example.com/a/b/c
www.example.com

# handle more than one.
$ url '%H' http://www.example.com/a/b/c http://www.github.com
www.example.com
www.github.com

$ url '%P' http://www.example.com/a/b/c
/a/b/c

DESCRIPTION

Decompose the URL and reformat it according to a template.

The formats

  • %a - the path,

  • %f - the fragment

  • %h - the hostname

  • %h - the hostname in punycode

  • %P - the password of the userinfo portion

  • %p - the port

  • %q - the query string

  • %s - the scheme

  • %u - the complete URL

  • %U - the username of the userinfo portion

COPYRIGHT

Copyright © 2020, brian d foy, all rights reserved.

LICENSE

You can use this code under the terms of the Artistic License 2.