Fix public link getDownloadUrl to return Webdav public link
This is for apps that use getDownloadUrl() to access the Webdav endpoint for example for streaming. Also happens when clicking on the download action of a file. Note that the regular visible download URL is still the same.
This commit is contained in:
parent
a1c4e2e635
commit
42091cecf9
2 changed files with 10 additions and 7 deletions
|
@ -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() {
|
||||||
|
|
||||||
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']))
|
||||||
|
|
Loading…
Reference in a new issue