]> git.decadent.org.uk Git - maypole.git/blobdiff - lib/Apache/MVC.pm
fix to bug in Apache::MVC location handling
[maypole.git] / lib / Apache / MVC.pm
index 0f6b7d0e9fc8c0dda03506ff398da25900b17cf0..d5909bf897daabe7fafc60ad3daab36ae555b5d4 100644 (file)
@@ -93,10 +93,30 @@ functionality. See L<Maypole> for these:
 
 sub get_request {
     my ($self, $r) = @_;
-    my $ar = ($MODPERL2) ? $r : Apache::Request->instance($r);
+    my $ar;
+    if ($MODPERL2) {
+       $ar = eval {require Apache2::Request} ? Apache2::Request->new($r) : $r;
+       }
+    else { $ar = Apache::Request->instance($r); }
     $self->ar($ar);
 }
 
+=item warn
+
+=cut
+
+sub warn {
+  my ($self,@args) = @_;
+  my ($package, $line) = (caller)[0,2];
+  if ( $args[0] and ref $self ) {
+    $self->{ar}->warn("[$package line $line] ", @args) ;
+  } else {
+    print "warn called by ", caller, " with ", @_, "\n";
+  }
+  return;
+}
+
+
 =item parse_location
 
 =cut
@@ -112,13 +132,20 @@ sub parse_location {
     for (keys %headers) {
         $self->headers_in->set($_, $headers{$_});
     }
+
     my $path = $self->ar->uri;
     my $loc  = $self->ar->location;
+
     {
         no warnings 'uninitialized';
         $path .= '/' if $path eq $loc;
-        $path =~ s/^($loc)?\///;
+       if ($loc =~ /\/$/) {
+         $path =~ s/^($loc)?//;
+       } else {
+         $path =~ s/^($loc)?\///;
+       }
     }
+
     $self->path($path);
     $self->parse_path;
     $self->parse_args;
@@ -224,7 +251,7 @@ sub _mod_perl_args {
     } else {
       my $body = $self->_prepare_body($apr);
       %args = %{$body->param};
-      my $uri = URI->new($self->ar->uri);
+      my $uri = URI->new($self->ar->unparsed_uri);
       foreach my $key ($uri->query_param) {
        if (ref $args{$key}) {
          push (@{$args{$key}}, $uri->query_param($key));