URI

 view release on metacpan or  search on metacpan

Changes  view on Meta::CPAN


   The query_param_delete() method was not able to delete
   the last parameter from a form.  Similar problem existing
   when deleting via query_param().  Patch by <awk@awks.org>.

   The query_form() method now allow an array or hash
   reference to be passed to set the value.  This makes it
   possible to set the value to an empty form, something that
   the old API did not allow.

   The query_keywords() method now allow an array reference
   to be passed to set the value.



2003-10-06   Gisle Aas <gisle@ActiveState.com>

   Release 1.27

   The URI module is now less strict about the values accepted
   for gopher_type attribute of gopher:-URLs.  Patch suggested

Changes  view on Meta::CPAN


   Typo in URI::ldap spotted by Graham Barr.



1999-06-24   Gisle Aas <gisle@aas.no>

   Release 1.03

   Escape all reserved query characters in the individual components
   of $uri->query_form and $uri->query_keywords.

   Make compatibility URI::URL->new("mailto:gisle@aas.no")->netloc
   work again.



1999-03-26   Gisle Aas <gisle@aas.no>

   Release 1.02

dist.ini  view on Meta::CPAN

skip = URI::urn::isbn
skip = URI::urn::oid
skip = URI::scp
skip = URI::sftp
trustme = URI => qr/^(?:STORABLE_freeze|STORABLE_thaw|TO_JSON|implementor)$/
trustme = URI::Escape => qr/^(?:escape_char)$/
trustme = URI::Heuristic => qr/^(?:MY_COUNTRY|uf_url|uf_urlstr)$/
trustme = URI::URL => qr/^(?:address|article|crack|dos_path|encoded822addr|eparams|epath|frag)$/
trustme = URI::URL => qr/^(?:full_path|groupart|keywords|local_path|mac_path|netloc|newlocal|params|path|path_components|print_on|query|strict|unix_path|url|vms_path)$/
trustme = URI::WithBase => qr/^(?:can|clone|eq|new_abs)$/
trustme = URI::_query => qr/^(?:equery|query|query_form|query_form_hash|query_keywords|query_param|query_param_append|query_param_delete)$/
trustme = URI::_segment => qr/^(?:new)$/
trustme = URI::_userpass => qr/^(?:password|user)$/
trustme = URI::file => qr/^(?:os_class)$/
trustme = URI::file::Base => qr/^(?:dir|file|new)$/
trustme = URI::file::FAT => qr/^(?:fix_path)$/
trustme = URI::file::Mac => qr/^(?:dir|file)$/
trustme = URI::file::OS2 => qr/^(?:file)$/
trustme = URI::file::Unix => qr/^(?:file)$/
trustme = URI::file::Win32 => qr/^(?:file|fix_path)$/
trustme = URI::ftp => qr/^(?:password|user|encrypt_mode)$/

lib/URI.pm  view on Meta::CPAN

value becomes an array reference.

Note that sequence information is lost.  This means that:

   $u->query_form_hash($u->query_form_hash);

is not necessarily a no-op, as it may reorder the key/value pairs.
The values returned by the query_param() method should stay the same
though.

=item $uri->query_keywords

=item $uri->query_keywords( $keywords, ... )

=item $uri->query_keywords( \@keywords )

Sets and returns query components that use the
keywords separated by "+" format.

The keywords can be set either by passing separate keywords directly
or by passing a reference to an array of keywords.  Passing an empty
array removes the query component, whereas passing no arguments at
all leaves the component unchanged.  The old value is always returned
as a list of separate words.

lib/URI/URL.pm  view on Meta::CPAN

    my $base = shift;
    my $allow_scheme = shift;
    $allow_scheme = $URI::URL::ABS_ALLOW_RELATIVE_SCHEME
	unless defined $allow_scheme;
    local $URI::ABS_ALLOW_RELATIVE_SCHEME = $allow_scheme;
    local $URI::ABS_REMOTE_LEADING_DOTS = $URI::URL::ABS_REMOTE_LEADING_DOTS;
    $self->SUPER::abs($base);
}

sub frag { shift->fragment(@_); }
sub keywords { shift->query_keywords(@_); }

# file:
sub local_path { shift->file; }
sub unix_path  { shift->file("unix"); }
sub dos_path   { shift->file("dos");  }
sub mac_path   { shift->file("mac");  }
sub vms_path   { shift->file("vms");  }

# mailto:
sub address { shift->to(@_); }

lib/URI/URL.pm  view on Meta::CPAN


$url->abs and $url->rel have an optional $base argument.  See
L<URI::WithBase>.

=item *

$url->frag: same as $uri->fragment

=item *

$url->keywords: same as $uri->query_keywords

=item *

$url->localpath and friends map to $uri->file.

=item *

$url->address and $url->encoded822addr: same as $uri->to for mailto URI

=item *

lib/URI/_query.pm  view on Meta::CPAN

            $self->query(undef);
        }
    }
    return if !defined($old) || !length($old) || !defined(wantarray);
    return unless $old =~ /=/; # not a form
    map { ( defined ) ? do { s/\+/ /g; uri_unescape($_) } : undef }
         map { /=/ ? split(/=/, $_, 2) : ($_ => undef)} split(/[&;]/, $old);
}

# Handle ...?dog+bones type of query
sub query_keywords
{
    my $self = shift;
    my $old = $self->query;
    if (@_) {
        # Try to set query string
	my @copy = @_;
	@copy = @{$copy[0]} if @copy == 1 && _is_array($copy[0]);
	for (@copy) { s/([;\/?:@&=+,\$\[\]%])/ URI::Escape::escape_char($1)/eg; }
	$self->query(@copy ? join('+', @copy) : undef);
    }

lib/URI/sip.pm  view on Meta::CPAN

    $paramstr =~ s/^;//o;
    return $paramstr;
}

# Inherited methods that make no sense for a SIP URI.
sub path {}
sub path_query {}
sub path_segments {}
sub abs { shift }
sub rel { shift }
sub query_keywords {}

1;

t/query.t  view on Meta::CPAN


$u->query_form(a => undef);
is $u, "?a";

$u->query_form("a[=&+#] " => " [=&+#]");
is $u, "?a%5B%3D%26%2B%23%5D+=+%5B%3D%26%2B%23%5D";

@q = $u->query_form;
is join(":", @q), "a[=&+#] : [=&+#]";

@q = $u->query_keywords;
ok !@q;

$u->query_keywords("a", "b");
is $u, "?a+b";

$u->query_keywords(" ", "+", "=", "[", "]");
is $u, "?%20+%2B+%3D+%5B+%5D";

@q = $u->query_keywords;
is join(":", @q), " :+:=:[:]";

@q = $u->query_form;
ok !@q;

$u->query(" +?=#");
is $u, "?%20+?=%23";

$u->query_keywords([qw(a b)]);
is $u, "?a+b";

# Same, but using array object
$u->query_keywords(Foo::Bar::Array->new([qw(a b)]));
is $u, "?a+b";

# Same, but using a stringifyable array object
$u->query_keywords(Foo::Bar::Stringy->new([qw(a b)]));
is $u, "?a_hello_b";

$u->query_keywords([]);
is $u, "";

# Same, but using array object
$u->query_keywords(Foo::Bar::Array->new([]));
is $u, "";

# Same, but using a stringifyable array object
$u->query_keywords(Foo::Bar::Stringy->new([]));
is $u, "?";

$u->query_form({ a => 1, b => 2 });
ok $u eq "?a=1&b=2" || $u eq "?b=2&a=1";

$u->query_form([ a => 1, b => 2 ]);
is $u, "?a=1&b=2";

# Same, but using array object
$u->query_form(Foo::Bar::Array->new([ a => 1, b => 2 ]));

t/sq-brackets.t  view on Meta::CPAN

  is( $u->query()                 , "par=value%5B1%5D&par%5B2%5D=value%5B2%5D", "query");
  is( $u->as_string()             , "http://root%5Buser%5D@[::1]/path_with_square_%5Bbrackets%5D?par=value%5B1%5D&par%5B2%5D=value%5B2%5D#fragment%5B2%5D", "as_string");
  is( $u->has_recognized_scheme() , "1", "has_recognized_scheme");
  is( $u->as_iri()                , "http://root%5Buser%5D@[::1]/path_with_square_%5Bbrackets%5D?par=value%5B1%5D&par%5B2%5D=value%5B2%5D#fragment%5B2%5D", "as_iri"); #TODO: utf8

  is( $u->abs( "/BASEDIR")->as_string() , "http://root%5Buser%5D@[::1]/path_with_square_%5Bbrackets%5D?par=value%5B1%5D&par%5B2%5D=value%5B2%5D#fragment%5B2%5D", "abs (no change)");
  is( $u->rel("../BASEDIR")             , "http://root%5Buser%5D@[::1]/path_with_square_%5Bbrackets%5D?par=value%5B1%5D&par%5B2%5D=value%5B2%5D#fragment%5B2%5D", "rel");

  is( $u->authority()                   , "root%5Buser%5D@[::1]", "authority" );
  is( $u->path_query()                  , "/path_with_square_%5Bbrackets%5D?par=value%5B1%5D&par%5B2%5D=value%5B2%5D", "path_query");
  is( $u->query_keywords()              , undef, "query_keywords");

  my @segments = $u->path_segments();
  is( join(" | ", @segments), " | path_with_square_[brackets]", "segments");
}


{ #-- form/query related tests
  my $u = URI->new("http://root[user]@[::1]/path_with_square_[brackets]/segment[2]?par=value[1]&par[2]=value[2]#fragment[2]");

  is( $u->query_form(), "4", "scalar: query_form");

xt/author/pod-coverage.t  view on Meta::CPAN

                                   qr/^(?:MY_COUNTRY|uf_url|uf_urlstr)$/
                                 ],
             'URI::URL' => [
                             qr/^(?:address|article|crack|dos_path|encoded822addr|eparams|epath|frag)$/,
                             qr/^(?:full_path|groupart|keywords|local_path|mac_path|netloc|newlocal|params|path|path_components|print_on|query|strict|unix_path|url|vms_path)$/
                           ],
             'URI::WithBase' => [
                                  qr/^(?:can|clone|eq|new_abs)$/
                                ],
             'URI::_query' => [
                                qr/^(?:equery|query|query_form|query_form_hash|query_keywords|query_param|query_param_append|query_param_delete)$/
                              ],
             'URI::_segment' => [
                                  qr/^(?:new)$/
                                ],
             'URI::_userpass' => [
                                   qr/^(?:password|user)$/
                                 ],
             'URI::file' => [
                              qr/^(?:os_class)$/
                            ],



( run in 2.136 seconds using v1.01-cache-2.11-cpan-299005ec8e3 )