Don't require trailing slash for projectroot
Don't require trailing slash for projectroot

--- a/config/gitphp.conf.defaults.php
+++ b/config/gitphp.conf.defaults.php
@@ -26,7 +26,6 @@
 /*
  * projectroot
  * Full directory on server where projects are located
- * (don't forget trailing slash!)
  */
 //$gitphp_conf['projectroot'] = '/pub/gitprojects/';
 

--- a/config/gitphp.conf.php.example
+++ b/config/gitphp.conf.php.example
@@ -13,7 +13,6 @@
 /*
  * projectroot
  * Full directory on server where projects are located
- * (don't forget trailing slash!)
  */
 //$gitphp_conf['projectroot'] = '/pub/gitprojects/';
 

--- a/include/git/Project.class.php
+++ b/include/git/Project.class.php
@@ -204,6 +204,9 @@
 	private function SetProject($project)
 	{
 		$projectRoot = GitPHP_Config::GetInstance()->GetValue('projectroot');
+		if (substr($projectRoot, -1) != '/')
+			$projectRoot .= '/';
+
 		$realProjectRoot = realpath($projectRoot);
 		$path = $projectRoot . $project;
 		$fullPath = realpath($path);
@@ -313,7 +316,11 @@
 	 */
 	public function GetPath()
 	{
-		return GitPHP_Config::GetInstance()->GetValue('projectroot') . $this->project;
+		$projectRoot = GitPHP_Config::GetInstance()->GetValue('projectroot');
+		if (substr($projectRoot, -1) != '/')
+			$projectRoot .= '/';
+
+		return $projectRoot . $this->project;
 	}
 
 	/**

--- a/include/git/ProjectListDirectory.class.php
+++ b/include/git/ProjectListDirectory.class.php
@@ -48,6 +48,9 @@
 		}
 
 		$this->projectDir = $projectDir;
+
+		if (substr($this->projectDir, -1) != '/')
+			$this->projectDir .= '/';
 
 		parent::__construct();
 	}

--- a/include/git/ProjectListFile.class.php
+++ b/include/git/ProjectListFile.class.php
@@ -58,6 +58,8 @@
 		}
 
 		$projectRoot = GitPHP_Config::GetInstance()->GetValue('projectroot');
+		if (substr($projectRoot, -1) != '/')
+			$projectRoot .= '/';
 
 		while (!feof($fp) && ($line = fgets($fp))) {
 			if (preg_match('/^([^\s]+)(\s.+)?$/', $line, $regs)) {

comments