From: Tim Düsterhus Date: Wed, 14 Dec 2011 18:49:01 +0000 (+0100) Subject: (add|remove)(Leading|Trailing)Slash rewritten X-Git-Tag: 2.0.0_Beta_1~1527^2 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=4c53e034b3e1fab1e5a367924c198860dd76c211;p=GitHub%2FWoltLab%2FWCF.git (add|remove)(Leading|Trailing)Slash rewritten --- diff --git a/wcfsetup/install/files/lib/util/FileUtil.class.php b/wcfsetup/install/files/lib/util/FileUtil.class.php index 8139aa3c28..037f2448e8 100644 --- a/wcfsetup/install/files/lib/util/FileUtil.class.php +++ b/wcfsetup/install/files/lib/util/FileUtil.class.php @@ -41,12 +41,7 @@ class FileUtil { * @return string $path */ public static function removeLeadingSlash($path) { - if (substr($path, 0, 1) == '/') { - return substr($path, 1); - } - else { - return $path; - } + return ltrim($path, '/'); } /** @@ -56,12 +51,7 @@ class FileUtil { * @return string $path */ public static function removeTrailingSlash($path) { - if (substr($path, -1) == '/') { - return substr($path, 0, -1); - } - else { - return $path; - } + return rtrim($path, '/'); } /** @@ -71,11 +61,7 @@ class FileUtil { * @return string $path */ public static function addTrailingSlash($path) { - if (substr($path, -1) != '/') { - return $path.'/'; - } - - return $path; + return rtrim($path, '/').'/'; } /** @@ -85,11 +71,7 @@ class FileUtil { * @return string $path */ public static function addLeadingSlash($path) { - if (substr($path, 0, 1) != '/') { - return '/'.$path; - } - - return $path; + return '/'.ltrim($path, '/'); } /**