.\" Automatically generated by Pod::Man 2.28 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "Mojo::URL 3pm" .TH Mojo::URL 3pm "2014-09-03" "perl v5.20.1" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Mojo::URL \- Uniform Resource Locator .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& use Mojo::URL; \& \& # Parse \& my $url \& = Mojo::URL\->new(\*(Aqhttp://sri:foobar@example.com:3000/foo/bar?foo=bar#23\*(Aq); \& say $url\->scheme; \& say $url\->userinfo; \& say $url\->host; \& say $url\->port; \& say $url\->path; \& say $url\->query; \& say $url\->fragment; \& \& # Build \& my $url = Mojo::URL\->new; \& $url\->scheme(\*(Aqhttp\*(Aq); \& $url\->userinfo(\*(Aqsri:foobar\*(Aq); \& $url\->host(\*(Aqexample.com\*(Aq); \& $url\->port(3000); \& $url\->path(\*(Aq/foo/bar\*(Aq); \& $url\->query\->param(foo => \*(Aqbar\*(Aq); \& $url\->fragment(23); \& say "$url"; .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" Mojo::URL implements a subset of \&\s-1RFC 3986\s0 and \&\s-1RFC 3987\s0 for Uniform Resource Locators with support for \s-1IDNA\s0 and IRIs. .SH "ATTRIBUTES" .IX Header "ATTRIBUTES" Mojo::URL implements the following attributes. .SS "base" .IX Subsection "base" .Vb 2 \& my $base = $url\->base; \& $url = $url\->base(Mojo::URL\->new); .Ve .PP Base of this \s-1URL,\s0 defaults to a Mojo::URL object. .SS "fragment" .IX Subsection "fragment" .Vb 2 \& my $fragment = $url\->fragment; \& $url = $url\->fragment(\*(Aqfoo\*(Aq); .Ve .PP Fragment part of this \s-1URL.\s0 .SS "host" .IX Subsection "host" .Vb 2 \& my $host = $url\->host; \& $url = $url\->host(\*(Aq127.0.0.1\*(Aq); .Ve .PP Host part of this \s-1URL.\s0 .SS "port" .IX Subsection "port" .Vb 2 \& my $port = $url\->port; \& $url = $url\->port(8080); .Ve .PP Port part of this \s-1URL.\s0 .SS "scheme" .IX Subsection "scheme" .Vb 2 \& my $scheme = $url\->scheme; \& $url = $url\->scheme(\*(Aqhttp\*(Aq); .Ve .PP Scheme part of this \s-1URL.\s0 .SS "userinfo" .IX Subsection "userinfo" .Vb 2 \& my $info = $url\->userinfo; \& $url = $url\->userinfo(\*(Aqroot:pass%3Bw0rd\*(Aq); .Ve .PP Userinfo part of this \s-1URL.\s0 .SH "METHODS" .IX Header "METHODS" Mojo::URL inherits all methods from Mojo::Base and implements the following new ones. .SS "authority" .IX Subsection "authority" .Vb 2 \& my $authority = $url\->authority; \& $url = $url\->authority(\*(Aqroot:pass%3Bw0rd@localhost:8080\*(Aq); .Ve .PP Authority part of this \s-1URL.\s0 .SS "clone" .IX Subsection "clone" .Vb 1 \& my $url2 = $url\->clone; .Ve .PP Clone this \s-1URL.\s0 .SS "host_port" .IX Subsection "host_port" .Vb 1 \& my $host_port = $url\->host_port; .Ve .PP Normalized version of \*(L"host\*(R" and \*(L"port\*(R". .PP .Vb 2 \& # "xn\-\-n3h.net:8080" \& Mojo::URL\->new(\*(Aqhttp://X.net:8080/test\*(Aq)\->host_port; .Ve .SS "ihost" .IX Subsection "ihost" .Vb 2 \& my $ihost = $url\->ihost; \& $url = $url\->ihost(\*(Aqxn\-\-bcher\-kva.ch\*(Aq); .Ve .PP Host part of this \s-1URL\s0 in punycode format. .PP .Vb 2 \& # "xn\-\-n3h.net" \& Mojo::URL\->new(\*(Aqhttp://X.net\*(Aq)\->ihost; .Ve .SS "is_abs" .IX Subsection "is_abs" .Vb 1 \& my $bool = $url\->is_abs; .Ve .PP Check if \s-1URL\s0 is absolute. .SS "new" .IX Subsection "new" .Vb 2 \& my $url = Mojo::URL\->new; \& my $url = Mojo::URL\->new(\*(Aqhttp://127.0.0.1:3000/foo?f=b&baz=2#foo\*(Aq); .Ve .PP Construct a new Mojo::URL object and \*(L"parse\*(R" \s-1URL\s0 if necessary. .SS "parse" .IX Subsection "parse" .Vb 1 \& $url = $url\->parse(\*(Aqhttp://127.0.0.1:3000/foo/bar?fo=o&baz=23#foo\*(Aq); .Ve .PP Parse relative or absolute \s-1URL.\s0 .PP .Vb 2 \& # "/test/123" \& $url\->parse(\*(Aq/test/123?foo=bar\*(Aq)\->path; \& \& # "example.com" \& $url\->parse(\*(Aqhttp://example.com/test/123?foo=bar\*(Aq)\->host; \& \& # "sri@example.com" \& $url\->parse(\*(Aqmailto:sri@example.com\*(Aq)\->path; .Ve .SS "path" .IX Subsection "path" .Vb 4 \& my $path = $url\->path; \& $url = $url\->path(\*(Aq/foo/bar\*(Aq); \& $url = $url\->path(\*(Aqfoo/bar\*(Aq); \& $url = $url\->path(Mojo::Path\->new); .Ve .PP Path part of this \s-1URL,\s0 relative paths will be merged with the existing path, defaults to a Mojo::Path object. .PP .Vb 2 \& # "http://example.com/DOM/HTML" \& Mojo::URL\->new(\*(Aqhttp://example.com/perldoc/Mojo\*(Aq)\->path(\*(Aq/DOM/HTML\*(Aq); \& \& # "http://example.com/perldoc/DOM/HTML" \& Mojo::URL\->new(\*(Aqhttp://example.com/perldoc/Mojo\*(Aq)\->path(\*(AqDOM/HTML\*(Aq); \& \& # "http://example.com/perldoc/Mojo/DOM/HTML" \& Mojo::URL\->new(\*(Aqhttp://example.com/perldoc/Mojo/\*(Aq)\->path(\*(AqDOM/HTML\*(Aq); .Ve .SS "path_query" .IX Subsection "path_query" .Vb 1 \& my $path_query = $url\->path_query; .Ve .PP Normalized version of \*(L"path\*(R" and \*(L"query\*(R". .SS "protocol" .IX Subsection "protocol" .Vb 1 \& my $proto = $url\->protocol; .Ve .PP Normalized version of \*(L"scheme\*(R". .PP .Vb 2 \& # "http" \& Mojo::URL\->new(\*(AqHtTp://example.com\*(Aq)\->protocol; .Ve .SS "query" .IX Subsection "query" .Vb 5 \& my $query = $url\->query; \& $url = $url\->query(replace => \*(Aqwith\*(Aq); \& $url = $url\->query([merge => \*(Aqwith\*(Aq]); \& $url = $url\->query({append => \*(Aqto\*(Aq}); \& $url = $url\->query(Mojo::Parameters\->new); .Ve .PP Query part of this \s-1URL,\s0 pairs in an array will be merged and pairs in a hash appended, defaults to a Mojo::Parameters object. .PP .Vb 2 \& # "2" \& Mojo::URL\->new(\*(Aqhttp://example.com?a=1&b=2\*(Aq)\->query\->param(\*(Aqb\*(Aq); \& \& # "http://example.com?a=2&c=3" \& Mojo::URL\->new(\*(Aqhttp://example.com?a=1&b=2\*(Aq)\->query(a => 2, c => 3); \& \& # "http://example.com?a=2&a=3" \& Mojo::URL\->new(\*(Aqhttp://example.com?a=1&b=2\*(Aq)\->query(a => [2, 3]); \& \& # "http://example.com?a=2&b=2&c=3" \& Mojo::URL\->new(\*(Aqhttp://example.com?a=1&b=2\*(Aq)\->query([a => 2, c => 3]); \& \& # "http://example.com?b=2" \& Mojo::URL\->new(\*(Aqhttp://example.com?a=1&b=2\*(Aq)\->query([a => undef]); \& \& # "http://example.com?a=1&b=2&a=2&c=3" \& Mojo::URL\->new(\*(Aqhttp://example.com?a=1&b=2\*(Aq)\->query({a => 2, c => 3}); .Ve .SS "to_abs" .IX Subsection "to_abs" .Vb 2 \& my $abs = $url\->to_abs; \& my $abs = $url\->to_abs(Mojo::URL\->new(\*(Aqhttp://example.com/foo\*(Aq)); .Ve .PP Clone relative \s-1URL\s0 and turn it into an absolute one using \*(L"base\*(R" or provided base \s-1URL.\s0 .PP .Vb 3 \& # "http://example.com/foo/baz.xml?test=123" \& Mojo::URL\->new(\*(Aqbaz.xml?test=123\*(Aq) \& \->to_abs(Mojo::URL\->new(\*(Aqhttp://example.com/foo/bar.html\*(Aq)); \& \& # "http://example.com/baz.xml?test=123" \& Mojo::URL\->new(\*(Aq/baz.xml?test=123\*(Aq) \& \->to_abs(Mojo::URL\->new(\*(Aqhttp://example.com/foo/bar.html\*(Aq)); \& \& # "http://example.com/foo/baz.xml?test=123" \& Mojo::URL\->new(\*(Aq//example.com/foo/baz.xml?test=123\*(Aq) \& \->to_abs(Mojo::URL\->new(\*(Aqhttp://example.com/foo/bar.html\*(Aq)); .Ve .SS "to_string" .IX Subsection "to_string" .Vb 1 \& my $str = $url\->to_string; .Ve .PP Turn \s-1URL\s0 into a string. .SH "OPERATORS" .IX Header "OPERATORS" Mojo::URL overloads the following operators. .SS "bool" .IX Subsection "bool" .Vb 1 \& my $bool = !!$url; .Ve .PP Always true. .SS "stringify" .IX Subsection "stringify" .Vb 1 \& my $str = "$url"; .Ve .PP Alias for \*(L"to_string\*(R". .SH "SEE ALSO" .IX Header "SEE ALSO" Mojolicious, Mojolicious::Guides, .