NAME
Mojo::URL - Uniform Resource Locator
SYNOPSIS
use Mojo::URL;
# Parse
my $url = Mojo::URL->new(
'http://sri:foobar@kraih.com:3000/foo/bar?foo=bar#23'
);
print $url->scheme;
print $url->userinfo;
print $url->host;
print $url->port;
print $url->path;
print $url->query;
print $url->fragment;
# Build
my $url = Mojo::URL->new;
$url->scheme('http');
$url->userinfo('sri:foobar');
$url->host('kraih.com');
$url->port(3000);
$url->path->parts(qw/foo bar/);
$url->query->params(foo => 'bar');
$url->fragment(23);
print "$url";
DESCRIPTION
Mojo::URL implements a subset of RFC 3986 for Uniform Resource Locators.
ATTRIBUTES
Mojo::URL implements the following attributes.
authority
my $authority = $url->autority;
$url = $url->authority('root:pass%3Bw0rd@localhost:8080');
base
my $base = $url->base;
$url = $url->base(Mojo::URL->new);
fragment
my $fragment = $url->fragment;
$url = $url->fragment('foo');
host
my $host = $url->host;
$url = $url->host('127.0.0.1');
port
my $port = $url->port;
$url = $url->port(8080);
scheme
my $scheme = $url->scheme;
$url = $url->scheme('http');
userinfo
my $userinfo = $url->userinfo;
$url = $url->userinfo('root:pass%3Bw0rd');
METHODS
Mojo::URL inherits all methods from Mojo::Base and implements the following new ones.
new
my $url = Mojo::URL->new;
my $url = Mojo::URL->new('http://127.0.0.1:3000/foo?f=b&baz=2#foo');
clone
my $url2 = $url->clone;
ihost
my $ihost = $url->ihost;
$url = $url->ihost('xn--bcher-kva.ch');
is_abs
my $is_abs = $url->is_abs;
parse
$url = $url->parse('http://127.0.0.1:3000/foo/bar?fo=o&baz=23#foo');
path
my $path = $url->path;
$url = $url->path('/foo/bar');
$url = $url->path(Mojo::Path->new);
query
my $query = $url->query;
$url = $url->query(name => 'value');
$url = $url->query([name => 'value']);
$url = $url->query(Mojo::Parameters->new);
to_abs
my $abs = $url->to_abs;
my $abs = $url->to_abs(Mojo::URL->new('http://kraih.com/foo'));
to_rel
my $rel = $url->to_rel;
my $rel = $url->to_rel(Mojo::URL->new('http://kraih.com/foo'));
to_string
my $string = $url->to_string;