From 6158899240e5d0e4026547e7583d9b5c7bfaad23 Mon Sep 17 00:00:00 2001 From: miqrogroove <1371835+miqrogroove@users.noreply.github.com> Date: Wed, 11 May 2022 21:56:07 -0400 Subject: [PATCH] Check webtrees rewrite_urls value during sign in. Fixes #1 --- module.php | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/module.php b/module.php index d03ddd0..bd879e3 100644 --- a/module.php +++ b/module.php @@ -26,6 +26,7 @@ use Fisharebest\Webtrees\Module\AbstractModule; use Fisharebest\Webtrees\Module\ModuleCustomInterface; use Fisharebest\Webtrees\Module\ModuleCustomTrait; +use Fisharebest\Webtrees\Validator; use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; use Psr\Http\Server\MiddlewareInterface; @@ -62,10 +63,15 @@ public function process(ServerRequestInterface $request, RequestHandlerInterface if ($request->getAttribute('route')->name === LoginPage::class) { $params = $request->getQueryParams(); $url = $params['url'] ?? ''; - if (substr_compare($url, '/my-page', -8) === 0) { - $params['url'] = substr($url, 0, -8); - $request = $request->withQueryParams($params); - } + if (Validator::attributes($request)->boolean('rewrite_urls', $default = false)) { + $end = '/my-page'; + } else { + $end = '%2Fmy-page'; + } + if (substr_compare($url, $end, -strlen($end)) === 0) { + $params['url'] = substr($url, 0, -strlen($end)); + $request = $request->withQueryParams($params); + } } return $handler->handle($request); @@ -108,7 +114,7 @@ public function customModuleAuthorName(): string */ public function customModuleVersion(): string { - return '1.0.02'; + return '1.0.03'; } /**