Skip to content

Commit

Permalink
Return early if path is root
Browse files Browse the repository at this point in the history
Signed-off-by: J0WI <J0WI@users.noreply.github.com>
  • Loading branch information
J0WI committed Mar 27, 2021
1 parent aec9c84 commit bb255c6
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions lib/private/Files/Filesystem.php
Original file line number Diff line number Diff line change
Expand Up @@ -800,10 +800,6 @@ public static function hasUpdated($path, $time) {
* @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
Expand All @@ -812,16 +808,20 @@ public static function normalizePath($path, $stripTrailingSlash = true, $isAbsol
*/
$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);
Expand Down

0 comments on commit bb255c6

Please sign in to comment.