NAME

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

SYNOPSIS

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

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

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

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

DESCRIPTION

Decompose the URL and reformat it according to

The formats

  • %a - the path

  • %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

There are also some bonus formats unrelated to the URL:

  • %n - newline

  • %t - tab

  • %% - literal percent

Methods

  • run( TEMPLATE, ARRAY )

    Format each URL in ARRAY according to TEMPLATE and return an array reference

COPYRIGHT

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

LICENSE

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