diff --git a/ChangeLog b/ChangeLog index 8d43311cb..9675a8e17 100644 --- a/ChangeLog +++ b/ChangeLog @@ -18,6 +18,7 @@ Core functionalities moved to plugins: Improvements: +* Make sure there is always a trailing slash for application_url * Do not show the checkbox "Show default swimlane" when there is no active swimlanes * Append filters instead of replacing value for users and categories dropdowns * Do not show empty swimlanes in public view diff --git a/app/Model/Config.php b/app/Model/Config.php index 8e51da245..bbc86a880 100644 --- a/app/Model/Config.php +++ b/app/Model/Config.php @@ -208,6 +208,11 @@ class Config extends Base { foreach ($values as $option => $value) { + // Be sure that a trailing slash is there for the url + if ($option === 'application_url' && ! empty($value) && substr($value, -1) !== '/') { + $value .= '/'; + } + $result = $this->db->table(self::TABLE)->eq('option', $option)->update(array('value' => $value)); if (! $result) { diff --git a/tests/units/Model/ConfigTest.php b/tests/units/Model/ConfigTest.php index c0ed0313a..832575b8a 100644 --- a/tests/units/Model/ConfigTest.php +++ b/tests/units/Model/ConfigTest.php @@ -7,6 +7,20 @@ use Core\Session; class ConfigTest extends Base { + public function testSaveApplicationUrl() + { + $c = new Config($this->container); + + $this->assertTrue($c->save(array('application_url' => 'http://localhost/'))); + $this->assertEquals('http://localhost/', $c->get('application_url')); + + $this->assertTrue($c->save(array('application_url' => 'http://localhost'))); + $this->assertEquals('http://localhost/', $c->get('application_url')); + + $this->assertTrue($c->save(array('application_url' => ''))); + $this->assertEquals('', $c->get('application_url')); + } + public function testDefaultValues() { $c = new Config($this->container); @@ -56,11 +70,4 @@ class ConfigTest extends Base session_id(''); unset($this->container['session']); } - - public function testSave() - { - $c = new Config($this->container); - $this->assertTrue($c->save(array('application_url' => 'http://localhost/'))); - $this->assertEquals('http://localhost/', $c->get('application_url')); - } }