aboutsummaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorVincent Petry <pvince81@owncloud.com>2016-01-07 13:37:18 +0100
committerVincent Petry <pvince81@owncloud.com>2016-01-07 13:37:18 +0100
commit9742e9b113ccc16d4644e07eeb651b3ba5fc348b (patch)
treed23de0c94d431b3d38cda5a85fe06d468401c8a5 /apps
parent336fe868b2ee3a4105b93b71a1e739c9e412237b (diff)
downloadnextcloud-server-9742e9b113ccc16d4644e07eeb651b3ba5fc348b.tar.gz
nextcloud-server-9742e9b113ccc16d4644e07eeb651b3ba5fc348b.zip
Add token in webdav download link of public page
Diffstat (limited to 'apps')
-rw-r--r--apps/files_sharing/js/public.js6
-rw-r--r--apps/files_sharing/tests/js/publicAppSpec.js6
2 files changed, 8 insertions, 4 deletions
diff --git a/apps/files_sharing/js/public.js b/apps/files_sharing/js/public.js
index af808447381..f2d6355d76a 100644
--- a/apps/files_sharing/js/public.js
+++ b/apps/files_sharing/js/public.js
@@ -155,7 +155,11 @@ OCA.Sharing.PublicApp = {
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);
+ 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)) {
filename = JSON.stringify(filename);
diff --git a/apps/files_sharing/tests/js/publicAppSpec.js b/apps/files_sharing/tests/js/publicAppSpec.js
index 2aaf758f3e3..cedc51f98f1 100644
--- a/apps/files_sharing/tests/js/publicAppSpec.js
+++ b/apps/files_sharing/tests/js/publicAppSpec.js
@@ -102,12 +102,12 @@ describe('OCA.Sharing.PublicApp tests', function() {
it('returns correct download URL for single files', function() {
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'))
- .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('/');
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() {
expect(fileList.getDownloadUrl(['a b c.txt', 'd e f.txt']))