Don't require trailing slash for self url
Don't require trailing slash for self url

--- a/config/gitphp.conf.defaults.php
+++ b/config/gitphp.conf.defaults.php
@@ -96,10 +96,6 @@
  * in urls.  If you leave this blank/commented the script
  * will try to guess the correct URL, but you can override
  * it here if it's not being guessed correctly.
- *
- * If only specifying the directory path (and omitting the
- * index.php filename), make sure to include the trailing
- * slash!
  */
 $gitphp_conf['self'] = 'http://localhost/gitphp/';
 

--- a/include/smartyplugins/function.scripturl.php
+++ b/include/smartyplugins/function.scripturl.php
@@ -9,8 +9,15 @@
 
 function smarty_function_scripturl($params, &$smarty)
 {
-	if (GitPHP_Config::GetInstance()->HasKey('self'))
-		return GitPHP_Config::GetInstance()->GetValue('self');
+	if (GitPHP_Config::GetInstance()->HasKey('self')) {
+		$selfurl = GitPHP_Config::GetInstance()->GetValue('self');
+		if (!empty($selfurl)) {
+			if (substr($selfurl, -4) != '.php') {
+				$selfurl = GitPHP_Util::AddSlash($selfurl);
+			}
+			return $selfurl;
+		}
+	}
 
 	if (isset($_SERVER['HTTPS']) && ($_SERVER['HTTPS'] == 'on'))
 		$scriptstr = 'https://';

comments