]> git.decadent.org.uk Git - maypole.git/blobdiff - lib/Maypole/CLI.pm
new warn function, other small trivial changes and fixes
[maypole.git] / lib / Maypole / CLI.pm
index 81a2fd5083b2e2d4d10908895ae1ad7fa8af04fa..8f8a50eb4cd0243a71ff514a644a04e652c0a9a6 100644 (file)
@@ -26,12 +26,20 @@ 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;
+    (my $uri_base = $self->config->uri_base) =~ s:/$::;
+    my $root = URI->new( $uri_base )->path;
     $self->{path} = $url->path;
-    $self->{path} =~ s/^$root//i if $root;
+    $self->{path} =~ s:^$root/?::i if $root;
     $self->parse_path;
     $self->parse_args($url);
 }
@@ -46,7 +54,7 @@ sub send_output { $buffer = shift->{output} }
 
 sub call_url {
     my $self = shift;
-    @ARGV = @_;
+    local @ARGV = @_;
     $package->handler() == OK and return $buffer;
 }