Skip to content

Commit 0c9b8ad

Browse files
committed
Return early if path is root
Signed-off-by: J0WI <[email protected]>
1 parent bfd9269 commit 0c9b8ad

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

lib/private/Files/Filesystem.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -800,10 +800,6 @@ public static function hasUpdated($path, $time) {
800800
* @return string
801801
*/
802802
public static function normalizePath($path, $stripTrailingSlash = true, $isAbsolutePath = false, $keepUnicode = false) {
803-
if (is_null(self::$normalizedPathCache)) {
804-
self::$normalizedPathCache = new CappedMemoryCache(2048);
805-
}
806-
807803
/**
808804
* FIXME: This is a workaround for existing classes and files which call
809805
* this function with another type than a valid string. This
@@ -812,16 +808,20 @@ public static function normalizePath($path, $stripTrailingSlash = true, $isAbsol
812808
*/
813809
$path = (string)$path;
814810

811+
if ($path === '') {
812+
return '/';
813+
}
814+
815+
if (is_null(self::$normalizedPathCache)) {
816+
self::$normalizedPathCache = new CappedMemoryCache(2048);
817+
}
818+
815819
$cacheKey = json_encode([$path, $stripTrailingSlash, $isAbsolutePath, $keepUnicode]);
816820

817821
if ($cacheKey && isset(self::$normalizedPathCache[$cacheKey])) {
818822
return self::$normalizedPathCache[$cacheKey];
819823
}
820824

821-
if ($path === '') {
822-
return '/';
823-
}
824-
825825
//normalize unicode if possible
826826
if (!$keepUnicode) {
827827
$path = \OC_Util::normalizeUnicode($path);

0 commit comments

Comments
 (0)