aboutsummaryrefslogtreecommitdiffhomepage
path: root/application/front/ShaarliMiddleware.php
diff options
context:
space:
mode:
Diffstat (limited to 'application/front/ShaarliMiddleware.php')
-rw-r--r--application/front/ShaarliMiddleware.php12
1 files changed, 11 insertions, 1 deletions
diff --git a/application/front/ShaarliMiddleware.php b/application/front/ShaarliMiddleware.php
index 707489d0..a2a3837b 100644
--- a/application/front/ShaarliMiddleware.php
+++ b/application/front/ShaarliMiddleware.php
@@ -40,7 +40,7 @@ class ShaarliMiddleware
40 */ 40 */
41 public function __invoke(Request $request, Response $response, callable $next): Response 41 public function __invoke(Request $request, Response $response, callable $next): Response
42 { 42 {
43 $this->container->basePath = rtrim($request->getUri()->getBasePath(), '/'); 43 $this->initBasePath($request);
44 44
45 try { 45 try {
46 if (!is_file($this->container->conf->getConfigFileExt()) 46 if (!is_file($this->container->conf->getConfigFileExt())
@@ -125,4 +125,14 @@ class ShaarliMiddleware
125 125
126 return true; 126 return true;
127 } 127 }
128
129 /**
130 * Initialize the URL base path if it hasn't been defined yet.
131 */
132 protected function initBasePath(Request $request): void
133 {
134 if (null === $this->container->basePath) {
135 $this->container->basePath = rtrim($request->getUri()->getBasePath(), '/');
136 }
137 }
128} 138}