Skip to content
Snippets Groups Projects
Commit fd79511d authored by Thomas Müller's avatar Thomas Müller
Browse files

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

Fix public link getDownloadUrl to return Webdav public link
parents 364dbe61 42091cec
No related branches found
No related tags found
No related merge requests found
...@@ -148,11 +148,14 @@ OCA.Sharing.PublicApp = { ...@@ -148,11 +148,14 @@ OCA.Sharing.PublicApp = {
if (this.fileList) { if (this.fileList) {
// TODO: move this to a separate PublicFileList class that extends OCA.Files.FileList (+ unit tests) // TODO: move this to a separate PublicFileList class that extends OCA.Files.FileList (+ unit tests)
this.fileList.getDownloadUrl = function (filename, dir) { this.fileList.getDownloadUrl = function (filename, dir, isDir) {
if ($.isArray(filename)) { 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); filename = JSON.stringify(filename);
} }
var path = dir || FileList.getCurrentDirectory();
var params = { var params = {
path: path, path: path,
files: filename files: filename
......
...@@ -101,12 +101,12 @@ describe('OCA.Sharing.PublicApp tests', function() { ...@@ -101,12 +101,12 @@ describe('OCA.Sharing.PublicApp tests', function() {
it('returns correct download URL for single files', function() { it('returns correct download URL for single files', function() {
expect(fileList.getDownloadUrl('some file.txt')) expect(fileList.getDownloadUrl('some file.txt'))
.toEqual(OC.webroot + '/index.php/s/sh4tok/download?path=%2Fsubdir&files=some%20file.txt'); .toEqual('/owncloud/public.php/webdav/subdir/some file.txt');
expect(fileList.getDownloadUrl('some file.txt', '/anotherpath/abc')) expect(fileList.getDownloadUrl('some file.txt', '/another path/abc'))
.toEqual(OC.webroot + '/index.php/s/sh4tok/download?path=%2Fanotherpath%2Fabc&files=some%20file.txt'); .toEqual('/owncloud/public.php/webdav/another path/abc/some file.txt');
fileList.changeDirectory('/'); fileList.changeDirectory('/');
expect(fileList.getDownloadUrl('some file.txt')) 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() { it('returns correct download URL for multiple files', function() {
expect(fileList.getDownloadUrl(['a b c.txt', 'd e f.txt'])) expect(fileList.getDownloadUrl(['a b c.txt', 'd e f.txt']))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment