Merge pull request #21503 from owncloud/public-fixdownloadlinktoken

Add token in webdav download link of public page
This commit is contained in:
Lukas Reschke 2016-01-07 13:55:32 +01:00
commit b9e49ae13a
2 changed files with 8 additions and 4 deletions

View File

@ -155,7 +155,11 @@ OCA.Sharing.PublicApp = {
this.fileList.getDownloadUrl = function (filename, dir, isDir) { this.fileList.getDownloadUrl = function (filename, dir, isDir) {
var path = dir || this.getCurrentDirectory(); var path = dir || this.getCurrentDirectory();
if (filename && !_.isArray(filename) && !isDir) { if (filename && !_.isArray(filename) && !isDir) {
return OC.getRootPath() + '/public.php/webdav' + OC.joinPaths(path, filename); var portPart = '';
if (OC.getPort()) {
portPart = ':' + OC.getPort();
}
return OC.getProtocol() + '://' + token + '@' + OC.getHost() + portPart + OC.getRootPath() + '/public.php/webdav' + OC.joinPaths(path, filename);
} }
if (_.isArray(filename)) { if (_.isArray(filename)) {
filename = JSON.stringify(filename); filename = JSON.stringify(filename);

View File

@ -102,12 +102,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('/owncloud/public.php/webdav/subdir/some file.txt'); .toEqual('https://sh4tok@example.com:9876/owncloud/public.php/webdav/subdir/some file.txt');
expect(fileList.getDownloadUrl('some file.txt', '/another path/abc')) expect(fileList.getDownloadUrl('some file.txt', '/another path/abc'))
.toEqual('/owncloud/public.php/webdav/another path/abc/some file.txt'); .toEqual('https://sh4tok@example.com:9876/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('/owncloud/public.php/webdav/some file.txt'); .toEqual('https://sh4tok@example.com:9876/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']))