mirror of
https://github.com/nextcloud/server.git
synced 2026-04-21 22:27:31 -04:00
Return early if path is root
Signed-off-by: J0WI <J0WI@users.noreply.github.com>
This commit is contained in:
parent
bfd926938f
commit
0c9b8ad051
1 changed files with 8 additions and 8 deletions
|
|
@ -800,10 +800,6 @@ class Filesystem {
|
|||
* @return string
|
||||
*/
|
||||
public static function normalizePath($path, $stripTrailingSlash = true, $isAbsolutePath = false, $keepUnicode = false) {
|
||||
if (is_null(self::$normalizedPathCache)) {
|
||||
self::$normalizedPathCache = new CappedMemoryCache(2048);
|
||||
}
|
||||
|
||||
/**
|
||||
* FIXME: This is a workaround for existing classes and files which call
|
||||
* this function with another type than a valid string. This
|
||||
|
|
@ -812,16 +808,20 @@ class Filesystem {
|
|||
*/
|
||||
$path = (string)$path;
|
||||
|
||||
if ($path === '') {
|
||||
return '/';
|
||||
}
|
||||
|
||||
if (is_null(self::$normalizedPathCache)) {
|
||||
self::$normalizedPathCache = new CappedMemoryCache(2048);
|
||||
}
|
||||
|
||||
$cacheKey = json_encode([$path, $stripTrailingSlash, $isAbsolutePath, $keepUnicode]);
|
||||
|
||||
if ($cacheKey && isset(self::$normalizedPathCache[$cacheKey])) {
|
||||
return self::$normalizedPathCache[$cacheKey];
|
||||
}
|
||||
|
||||
if ($path === '') {
|
||||
return '/';
|
||||
}
|
||||
|
||||
//normalize unicode if possible
|
||||
if (!$keepUnicode) {
|
||||
$path = \OC_Util::normalizeUnicode($path);
|
||||
|
|
|
|||
Loading…
Reference in a new issue