From 0a10ec6e3379c314982ce4aeee0f3d8ae3ac9b84 Mon Sep 17 00:00:00 2001 From: "milos.brecher" Date: Tue, 3 Dec 2024 04:22:34 +0100 Subject: [PATCH 1/2] removed redundant removing ending slash from $basePath - after correction of UrlScript --- src/Application/MicroPresenter.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Application/MicroPresenter.php b/src/Application/MicroPresenter.php index 7ee8b0db4..ac1ca1678 100644 --- a/src/Application/MicroPresenter.php +++ b/src/Application/MicroPresenter.php @@ -124,8 +124,8 @@ public function createTemplate(?string $class = null, ?callable $latteFactory = $template->context = $this->context; if ($this->httpRequest) { $url = $this->httpRequest->getUrl(); - $template->baseUrl = rtrim($url->getBaseUrl(), '/'); - $template->basePath = rtrim($url->getBasePath(), '/'); + $template->baseUrl = $url->getBaseUrl(); + $template->basePath = $url->getBasePath(); } return $template; From 85eea5f4d89e0e2a3cb7b0a6f7cc6716311bc049 Mon Sep 17 00:00:00 2001 From: "milos.brecher" Date: Tue, 3 Dec 2024 04:29:15 +0100 Subject: [PATCH 2/2] simplifying injecting $basePath + $baseUrl using corrected UrlScript methods --- src/Bridges/ApplicationLatte/TemplateFactory.php | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/Bridges/ApplicationLatte/TemplateFactory.php b/src/Bridges/ApplicationLatte/TemplateFactory.php index 1f2cbb764..14a9d7022 100644 --- a/src/Bridges/ApplicationLatte/TemplateFactory.php +++ b/src/Bridges/ApplicationLatte/TemplateFactory.php @@ -49,17 +49,15 @@ public function createTemplate(?UI\Control $control = null, ?string $class = nul $presenter = $control?->getPresenterIfExists(); // default parameters - $baseUrl = $this->httpRequest - ? rtrim($this->httpRequest->getUrl()->withoutUserInfo()->getBaseUrl(), '/') - : null; + $url = $this->httpRequest?->getUrl()->withoutUserInfo(); $flashes = $presenter instanceof UI\Presenter && $presenter->hasFlashSession() ? (array) $presenter->getFlashSession()->get($control->getParameterId('flash')) : []; $params = [ 'user' => $this->user, - 'baseUrl' => $baseUrl, - 'basePath' => $baseUrl ? preg_replace('#https?://[^/]+#A', '', $baseUrl) : null, + 'baseUrl' => $url?->getBaseUrl(), + 'basePath' => $url?->getBasePath(), 'flashes' => $flashes, 'control' => $control, 'presenter' => $presenter,