From 4c53e034b3e1fab1e5a367924c198860dd76c211 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim=20D=C3=BCsterhus?= Date: Wed, 14 Dec 2011 19:49:01 +0100 Subject: [PATCH] (add|remove)(Leading|Trailing)Slash rewritten --- .../install/files/lib/util/FileUtil.class.php | 26 +++---------------- 1 file changed, 4 insertions(+), 22 deletions(-) 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, '/'); } /** -- 2.20.1