]> git.decadent.org.uk Git - maypole.git/blobdiff - lib/Maypole/CLI.pm
added preprocess_location method
[maypole.git] / lib / Maypole / CLI.pm
index 504d0b428a18596aa373a66d4643f7bbe207814b..39abf1546370987a26f16fb00d57c584bf14b045 100644 (file)
@@ -26,13 +26,23 @@ sub import {
 
 sub get_template_root { $ENV{MAYPOLE_TEMPLATES} || "." }
 
+sub warn {
+    my ($self,@args) = @_;
+    my ($package, $line) = (caller)[0,2];
+    warn "[$package line $line] ", @args ;
+    return;
+}
+
 sub parse_location {
     my $self = shift;
     my $url  = URI->new( shift @ARGV );
-    my $root = URI->new( $self->config->uri_base )->path;
+
+    $self->preprocess_location();
+
+    (my $uri_base = $self->config->uri_base) =~ s:/$::;
+    my $root = URI->new( $uri_base )->path;
     $self->{path} = $url->path;
-    $self->{path} .= '/' if $self->{path} eq $root;
-    $self->{path} =~ s/^$root//i if $root;
+    $self->{path} =~ s:^$root/?::i if $root;
     $self->parse_path;
     $self->parse_args($url);
 }
@@ -47,7 +57,7 @@ sub send_output { $buffer = shift->{output} }
 
 sub call_url {
     my $self = shift;
-    @ARGV = @_;
+    local @ARGV = @_;
     $package->handler() == OK and return $buffer;
 }
 
@@ -137,6 +147,8 @@ functionality. See L<Maypole> for these:
 
 =item send_output
 
+=item warn
+
 =back
 
 =cut