Skip to content

Commit 5986863

Browse files
committed
UnifiedSearchController: strip webroot from URL before finding a route
This should fix route matching in UnifiedSearchController on setups with Nextcloud in a subfolder (webroot). Fixes: #24144 Signed-off-by: Jonas Meurer <jonas@freesources.org>
1 parent 2a63219 commit 5986863

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

core/Controller/UnifiedSearchController.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,16 @@ protected function getRouteInformation(string $url): array {
123123

124124
if ($url !== '') {
125125
$urlParts = parse_url($url);
126+
$urlPath = $urlParts['path'];
127+
128+
// Optionally strip webroot from URL
129+
$webroot = \OC::$WEBROOT;
130+
if ($webroot !== '' && substr($urlPath, 0, strlen($webroot))) {
131+
$urlPath = substr($urlPath, strlen($webroot));
132+
}
126133

127134
try {
128-
$parameters = $this->router->findMatchingRoute($urlParts['path']);
135+
$parameters = $this->router->findMatchingRoute($urlPath);
129136

130137
// contacts.PageController.index => contacts.Page.index
131138
$route = $parameters['caller'];

0 commit comments

Comments
 (0)