aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoranon2025-08-21 00:18:45 +0200
committeranon2025-08-21 00:18:45 +0200
commit32f898c9515f944eef79ecd719bffe5ae63ac0ae (patch)
treebc6f18c562e30a75a97676af74d94c720e1c664b
parente1bf0fe5b484aade6fe127f74065a464484bfacb (diff)
downloadgorillanest-32f898c9515f944eef79ecd719bffe5ae63ac0ae.tar.xz
gorillanest-32f898c9515f944eef79ecd719bffe5ae63ac0ae.tar.zst
optimize
-rwxr-xr-xgorillanest.pl.cgi12
-rwxr-xr-xgorillanest.pl.fcgi2
2 files changed, 8 insertions, 6 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;
}
}
diff --git a/gorillanest.pl.fcgi b/gorillanest.pl.fcgi
index f4c0687..d44df66 100755
--- a/gorillanest.pl.fcgi
+++ b/gorillanest.pl.fcgi
@@ -6,7 +6,7 @@ use warnings;
use Syntax::Keyword::Try;
use FCGI;
-require "gorillanest.pl.cgi";
+BEGIN { require 'gorillanest.pl.cgi'; }
our $request = FCGI::Request();