On Tue, 2002-09-03 at 22:56, Gisle Aas wrote:

> > > 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 !~ /&/) ? ';' : '&';

Yep, that's kind of a "simple" case, but I was more looking after making
an educated guess when they both are present in the query.  Then
checking if it has something that looks like "&foo=bar" (or ";foo=bar"
if you prefer), could help a bit further.  But it might just be
overkill, unpredictable and hard to document... YMMV.

> > > 2) how do we know
> > > what to use for joining parameters.
> > 
> > How about using a instance variable in URI, something like this:
[...]
> 
> Problem here is that URI objects are just the blessed URI string.
> There is no room for instance variables.

Ah, I was unaware of that.

> 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"

Shouldn't that last statement print "?foo=1&foo=2&foo=3" or did I get
something wrong here?

Anyway, I think I see the problem now.  query_param could do some tricks
though, like doing a query_sepchar before anything else, and
concatenating the guessed separator to the end of the query string so
that it would always be there.  The problem (though aesthetic only ?)
then becomes how to get rid of the trailing separator char.  Dirty? 
Maybe.

However, if the query_param method interface has been there for only a
couple of days now, perhaps it wouldn't be impossible to change it to
have the sepchar there and quickly release URI-1.23.  I don't have the
previous messages around any more, but ISTR there was some problem with
the even/odd-number-of-args approach?

Cheers,
-- 
\/ille Skytt�
ville.skytta at iki.fi

Reply via email to