Merge pull request #6097 from owncloud/extstorage-ftptrailingslash

Add trailing slash in FTP root path when missing
This commit is contained in:
Morris Jobke 2013-11-28 04:52:08 -08:00
commit 3a31f7eb4a
2 changed files with 15 additions and 0 deletions

View File

@ -35,6 +35,9 @@ class FTP extends \OC\Files\Storage\StreamWrapper{
if ( ! $this->root || $this->root[0]!='/') {
$this->root='/'.$this->root;
}
if (substr($this->root, -1) !== '/') {
$this->root .= '/';
}
} else {
throw new \Exception();
}

View File

@ -48,5 +48,17 @@ class FTP extends Storage {
$config['secure'] = 'true';
$instance = new \OC\Files\Storage\FTP($config);
$this->assertEquals('ftps://ftp:ftp@localhost/', $instance->constructUrl(''));
$config['root'] = '';
$instance = new \OC\Files\Storage\FTP($config);
$this->assertEquals('ftps://ftp:ftp@localhost/somefile.txt', $instance->constructUrl('somefile.txt'));
$config['root'] = '/abc';
$instance = new \OC\Files\Storage\FTP($config);
$this->assertEquals('ftps://ftp:ftp@localhost/abc/somefile.txt', $instance->constructUrl('somefile.txt'));
$config['root'] = '/abc/';
$instance = new \OC\Files\Storage\FTP($config);
$this->assertEquals('ftps://ftp:ftp@localhost/abc/somefile.txt', $instance->constructUrl('somefile.txt'));
}
}