From 05464cb18939d41c868684d5ff9b2b362e561152 Mon Sep 17 00:00:00 2001 From: Ben Roberts Date: Sun, 26 Jun 2011 18:12:50 +0100 Subject: [PATCH] Updated makeAbsoluteUrl to handle already absolute paths --- source/lib/SihnonFramework/Main.class.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/source/lib/SihnonFramework/Main.class.php b/source/lib/SihnonFramework/Main.class.php index d236422..c841c5a 100644 --- a/source/lib/SihnonFramework/Main.class.php +++ b/source/lib/SihnonFramework/Main.class.php @@ -237,7 +237,18 @@ class SihnonFramework_Main { } } + /** + * Returns the canonical form of the given path, made absolute if relative + * + * @param string $relative_path + * @return string + */ public static function makeAbsolutePath($relative_path) { + if (preg_match('#^/#', $relative_path)) { + // This path is already absolute, just canonicalise it + return realpath($relative_path); + } + $absolute_path = getcwd() . DIRECTORY_SEPARATOR . $relative_path; return realpath($absolute_path); }