Ville Skytt� <[EMAIL PROTECTED]> writes:

> > Some have suggested that $u->query_form should just split on both
> > [&;].  I have two problems with that; 1) I'm not totally convinced
> > that URIs like ?foo=1;2;3&bar=1 does not exist and
> 
> Hmm.  I wonder if anything that accepts both of delimiters works too
> well with them mixed.  One way could be to use some heuristics like this
> (probably needs work, kind of hacky):
> 
>     my $schar = ($qstring =~ /&[^;]+?=/) ? '&' : ';';

I think I would make it:

   $schar = ($qstring =~ /;/ && $qstring !~ /&/) ? ';' : '&';

> > 2) how do we know
> > what to use for joining parameters.
> 
> How about using a instance variable in URI, something like this:
> 
>    $u = URI->new("", "http");
> 
>    $u->query_param(foo => 1, 2, 3);
> 
>    $u->query_sepchar('&');   # '&' is the default
>    print $u->query;          # prints foo=1&foo=2&foo=3
> 
>    $u->query_sepchar(';');
>    print $u->query;          # prints foo=1;foo=2;foo=3
> 
> ...and if anything !~ /^[;&]$/ would be passed to query_sepchar, it
> would carp() and revert to '&'.

Problem here is that URI objects are just the blessed URI string.
There is no room for instance variables.  We could still have
$u->query_sepchar method like you suggest that simply modify the query
string.  The old setting is guessed with the expression above.

Problem is when there is only a single parameter or no query at all,
then the value reverts back to '&'.

    $u->query_param(foo => 1..3);
    $u->query_sepchar(';');
    print $u;                 # prints "?foo=1;foo=2;foo=3"
    print $u->query_sepchar;  # prints ";"

    $u->query_param(foo => 1);
    print $u;                 # prints "?foo=1"
    print $u->query-sepchar;  # prints "&"

    $u->query_param(foo => 1..3);
    print $u;                 # prints "?foo=1;foo=2;foo=3"

Regards,
Gisle

Reply via email to