From 12ca5e62b96a7bec59997c7702951156537e4eba Mon Sep 17 00:00:00 2001 From: Maxime Besson Date: Tue, 30 Aug 2022 20:14:18 +0200 Subject: [PATCH] Allow .html routes to call a sub --- lemonldap-ng-common/lib/Lemonldap/NG/Common/PSGI/Router.pm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lemonldap-ng-common/lib/Lemonldap/NG/Common/PSGI/Router.pm b/lemonldap-ng-common/lib/Lemonldap/NG/Common/PSGI/Router.pm index 1c622fb9d..28a32190b 100644 --- a/lemonldap-ng-common/lib/Lemonldap/NG/Common/PSGI/Router.pm +++ b/lemonldap-ng-common/lib/Lemonldap/NG/Common/PSGI/Router.pm @@ -56,7 +56,7 @@ sub genRoute { else { $dest ||= $word; } - if ( $dest =~ /^(.+)\.html$/ ) { + if ( $word =~ /^(.+)\.html$/ and $word eq $dest ) { my $tpl = $1 or die; $self->logger->debug("route $dest will use $tpl"); $routes->{$word} = sub { $self->sendHtml( $_[1], $tpl ) }; @@ -305,8 +305,8 @@ the subroutine will be called with the word of path_info as second argument =item 'something.html': -if $word finishes with '.html', then sendHtml() will be called with -'something.tpl' as template name. In this case, $dest is not used. +if $word finishes with '.html', and $dest is undef, then sendHtml() will be +called with 'something.tpl' as template name. =back