diff options
| author | anon | 2025-08-21 00:18:45 +0200 |
|---|---|---|
| committer | anon | 2025-08-21 00:18:45 +0200 |
| commit | 32f898c9515f944eef79ecd719bffe5ae63ac0ae (patch) | |
| tree | bc6f18c562e30a75a97676af74d94c720e1c664b /gorillanest.pl.cgi | |
| parent | e1bf0fe5b484aade6fe127f74065a464484bfacb (diff) | |
| download | gorillanest-32f898c9515f944eef79ecd719bffe5ae63ac0ae.tar.xz gorillanest-32f898c9515f944eef79ecd719bffe5ae63ac0ae.tar.zst | |
optimize
Diffstat (limited to 'gorillanest.pl.cgi')
| -rwxr-xr-x | gorillanest.pl.cgi | 12 |
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; } } |
