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

        # get the path
        $ 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

  • %A - the addresses

  • %f - the fragment

  • %h - the hostname, with domain info

  • %H - the hostname without domain info

  • %i - the hostname in punycode

  • %I - space-separated list of IP addresses for the host

  • %P - the password of the userinfo portion

  • %p - the port

  • %q - the query string

  • %s - the scheme

  • %S - the public suffix

  • %u - the complete URL

  • %U - the username of the userinfo portion

COPYRIGHT

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

LICENSE

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