Re: Absolutizing URIs
Gisle Aas (gisle@aas.no)
22 Jul 1999 16:38:45 +0200
gcarvell@bpd.treas.gov writes:
> I'm having trouble making an absolute URI from an existing URI object
> and a relative link. A link to an in-page anchor such as this '#foo?'
> can be absolutized with no problems, but a link like this '#foo?'
> drops the parent URI's filename when made absolute.
>
> This works as expected:
>
> $a = URI->new_abs('#foo', 'http://www.bar.com/file.html');
> -> http://www.bar.com/file.html#foo
>
> But this drops the filename from the result URI:
>
> $b = URI->new_abs('#foo?', 'http://www.bar.com/file.html');
> -> http://www.bar.com/#foo?
>
> Is this a bug
Yup. This patch should make things better. Will be in URI-1.04 when
it is ready.
Index: URI/_generic.pm
===================================================================
RCS file: /home/cvs/aas/perl/mods/uri/URI/_generic.pm,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -u -r1.15 -r1.16
--- _generic.pm 1999/07/22 12:15:25 1.15
+++ _generic.pm 1999/07/22 12:29:02 1.16
@@ -138,7 +138,7 @@
my $path = $self->path;
return $abs if $path =~ m,^/,;
- if (!length($path) && $$self !~ /\?/) {
+ if (!length($path) && !defined($self->query)) {
my $abs = $base->clone;
$abs->fragment($self->fragment);
return $abs;
Regards,
Gisle
or to calling the content
> method? Or am I misusing this object.
>
> >> my script fragment >>
> $sub = sub { my $answer = [ "some strings", "more strings", "etc" ];
> $$answer[$count++]; };
> $c->send_response($sub);