aboutsummaryrefslogtreecommitdiff
path: root/gorillanest.pl.cgi
diff options
context:
space:
mode:
Diffstat (limited to 'gorillanest.pl.cgi')
-rwxr-xr-xgorillanest.pl.cgi12
1 files changed, 7 insertions, 5 deletions
diff --git a/gorillanest.pl.cgi b/gorillanest.pl.cgi
index 4447e17..f71f6e1 100755
--- a/gorillanest.pl.cgi
+++ b/gorillanest.pl.cgi
@@ -70,12 +70,13 @@ sub serve_template {
}
my %routes = (
- '/' => sub { serve_template("index.tt", @_) },
- '/~([a-zA-Z0-9_.]+)' => sub { serve_template("index_user.tt", @_) },
- '/~([a-zA-Z0-9_.]+)/([a-zA-Z0-9_.]+)' => sub { serve_template("repository.tt", @_) },
+ '/' => sub { serve_template("index.tt", @_) },
+ '/~([\w+.])' => sub { serve_template("index_user.tt", @_) },
+ '/~([\w+.])/([\w+.]+)' => sub { serve_template("repository.tt", @_) },
);
+my %route_regex_cache = map { $_ => qr{^$_$} } keys %routes;
-my $public = 'git/public';
+my $public = 'repos/';
my $dbfile = 'gorillanest.sqlite3';
my %data = (
found => 0,
@@ -91,9 +92,10 @@ sub master {
my $uri = $ENV{'REQUEST_URI'} || '/';
for my $pattern (keys %routes) {
- if ($uri =~ m{^$pattern$}) {
+ if ($uri =~ $route_regex_cache{$pattern}) {
my $handler = $routes{$pattern};
$handler->($uri, $1, $2, $3);
+ return;
}
}