Permalink
Browse files

Refix detectServerUrl() in REST case.

  • Loading branch information...
1 parent 5aa4d8f commit 4709f1816620e4deaa5d0a30c07061c46fdb3a97 @cdujeu cdujeu committed Sep 24, 2016
Showing with 6 additions and 9 deletions.
  1. +6 −9 core/src/core/src/pydio/Core/Utils/ApplicationState.php
@@ -22,6 +22,7 @@
use Pydio\Core\Model\RepositoryInterface;
use Pydio\Core\Services\ConfService;
+use Pydio\Core\Utils\Vars\PathUtils;
use Pydio\Log\Core\Logger;
defined('AJXP_EXEC') or die('Access not allowed');
@@ -195,15 +196,11 @@ public static function detectServerURL($withURI = false, $forceInternal = false)
return "$protocol://$name$port";
} else {
$uri = dirname($_SERVER["REQUEST_URI"]);
- $api = self::getSapiRestBase();
- if (!empty($api)) {
- $api .= '/';
- if(strpos($uri, $api) === 0){
- $uri = '/';
- }else{
- // Keep only before api base
- $uri = array_shift(explode($api, $uri));
- }
+ $apiBase = self::getSapiRestBase();
+ if (!empty($apiBase)) {
+ // apiBase must be /path/to/pydio/endpoint => remove endpoint
+ $uri = PathUtils::forwardSlashDirname(rtrim($apiBase));
+ if(empty($uri)) $uri = "/";
}
return "$protocol://$name$port" . $uri;
}

0 comments on commit 4709f18

Please sign in to comment.