Merge pull request #6097 from owncloud/extstorage-ftptrailingslash
Add trailing slash in FTP root path when missing
This commit is contained in:
commit
3a31f7eb4a
|
@ -35,6 +35,9 @@ class FTP extends \OC\Files\Storage\StreamWrapper{
|
||||||
if ( ! $this->root || $this->root[0]!='/') {
|
if ( ! $this->root || $this->root[0]!='/') {
|
||||||
$this->root='/'.$this->root;
|
$this->root='/'.$this->root;
|
||||||
}
|
}
|
||||||
|
if (substr($this->root, -1) !== '/') {
|
||||||
|
$this->root .= '/';
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new \Exception();
|
throw new \Exception();
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,5 +48,17 @@ class FTP extends Storage {
|
||||||
$config['secure'] = 'true';
|
$config['secure'] = 'true';
|
||||||
$instance = new \OC\Files\Storage\FTP($config);
|
$instance = new \OC\Files\Storage\FTP($config);
|
||||||
$this->assertEquals('ftps://ftp:ftp@localhost/', $instance->constructUrl(''));
|
$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'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue