diff options
author | Frederic Guillot <fred@kanboard.net> | 2015-09-30 22:21:35 -0400 |
---|---|---|
committer | Frederic Guillot <fred@kanboard.net> | 2015-09-30 22:21:35 -0400 |
commit | 792d5a20bcb4926c91311afced67ddd008c3b79e (patch) | |
tree | 93ceaa5a5205bcb22fa00eaf91be95d5527bebc6 | |
parent | 8970fba41f9ecf46e9d4e477aeb11f81f84d96c7 (diff) |
Make sure there is always a trailing slash for application_url
-rw-r--r-- | ChangeLog | 1 | ||||
-rw-r--r-- | app/Model/Config.php | 5 | ||||
-rw-r--r-- | tests/units/Model/ConfigTest.php | 21 |
3 files changed, 20 insertions, 7 deletions
@@ -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 8e51da24..bbc86a88 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 c0ed0313..832575b8 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')); - } } |