Merge pull request #20688 from owncloud/publiclink-getdownloadurl-webdav

Fix public link getDownloadUrl to return Webdav public link
This commit is contained in:
Thomas Müller 2015-11-30 15:07:36 +01:00
commit fd79511d68
2 changed files with 10 additions and 7 deletions

View File

@ -148,11 +148,14 @@ OCA.Sharing.PublicApp = {
if (this.fileList) {
// TODO: move this to a separate PublicFileList class that extends OCA.Files.FileList (+ unit tests)
this.fileList.getDownloadUrl = function (filename, dir) {
if ($.isArray(filename)) {
this.fileList.getDownloadUrl = function (filename, dir, isDir) {
var path = dir || this.getCurrentDirectory();
if (filename && !_.isArray(filename) && !isDir) {
return OC.getRootPath() + '/public.php/webdav' + OC.joinPaths(path, filename);
}
if (_.isArray(filename)) {
filename = JSON.stringify(filename);
}
var path = dir || FileList.getCurrentDirectory();
var params = {
path: path,
files: filename

View File

@ -101,12 +101,12 @@ describe('OCA.Sharing.PublicApp tests', function() {
it('returns correct download URL for single files', function() {
expect(fileList.getDownloadUrl('some file.txt'))
.toEqual(OC.webroot + '/index.php/s/sh4tok/download?path=%2Fsubdir&files=some%20file.txt');
expect(fileList.getDownloadUrl('some file.txt', '/anotherpath/abc'))
.toEqual(OC.webroot + '/index.php/s/sh4tok/download?path=%2Fanotherpath%2Fabc&files=some%20file.txt');
.toEqual('/owncloud/public.php/webdav/subdir/some file.txt');
expect(fileList.getDownloadUrl('some file.txt', '/another path/abc'))
.toEqual('/owncloud/public.php/webdav/another path/abc/some file.txt');
fileList.changeDirectory('/');
expect(fileList.getDownloadUrl('some file.txt'))
.toEqual(OC.webroot + '/index.php/s/sh4tok/download?path=%2F&files=some%20file.txt');
.toEqual('/owncloud/public.php/webdav/some file.txt');
});
it('returns correct download URL for multiple files', function() {
expect(fileList.getDownloadUrl(['a b c.txt', 'd e f.txt']))