]> source.dussan.org Git - nextcloud-server.git/commitdiff
Add token in webdav download link of public page
authorVincent Petry <pvince81@owncloud.com>
Thu, 7 Jan 2016 12:37:18 +0000 (13:37 +0100)
committerVincent Petry <pvince81@owncloud.com>
Thu, 7 Jan 2016 12:37:18 +0000 (13:37 +0100)
apps/files_sharing/js/public.js
apps/files_sharing/tests/js/publicAppSpec.js

index af808447381eb0ff9a11bbeabd4db5ea33564a7c..f2d6355d76af9b5e4e00517f5c9f0ac8ab8ef881 100644 (file)
@@ -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);
index 2aaf758f3e36bc3662fbac6b5a6e3f125c989ca3..cedc51f98f1c1611f3cd4c265359baf58476bfd8 100644 (file)
@@ -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']))