]> source.dussan.org Git - nextcloud-server.git/commitdiff
Construct valid URL
authorRoeland Jago Douma <rullzer@owncloud.com>
Wed, 3 Feb 2016 10:29:36 +0000 (11:29 +0100)
committerRoeland Jago Douma <rullzer@owncloud.com>
Wed, 3 Feb 2016 10:29:36 +0000 (11:29 +0100)
apps/files_sharing/js/public.js
apps/files_sharing/tests/js/publicAppSpec.js

index f2d6355d76af9b5e4e00517f5c9f0ac8ab8ef881..bc609f04f797dff8ddc903a26e83a1977c0a4384 100644 (file)
@@ -155,11 +155,7 @@ OCA.Sharing.PublicApp = {
                        this.fileList.getDownloadUrl = function (filename, dir, isDir) {
                                var path = dir || this.getCurrentDirectory();
                                if (filename && !_.isArray(filename) && !isDir) {
-                                       var portPart = '';
-                                       if (OC.getPort()) {
-                                               portPart = ':' + OC.getPort();
-                                       }
-                                       return OC.getProtocol() + '://' + token + '@' + OC.getHost() + portPart + OC.getRootPath() + '/public.php/webdav' + OC.joinPaths(path, filename);
+                                       return OC.getProtocol() + '://' + token + '@' + OC.getHost() + OC.getRootPath() + '/public.php/webdav' + OC.joinPaths(path, filename);
                                }
                                if (_.isArray(filename)) {
                                        filename = JSON.stringify(filename);
index 17b7ffc97989ee8761fe9116d3bc54922867a543..8561836d77ce50d5ff786c24c097794a25ed0a2b 100644 (file)
 
 describe('OCA.Sharing.PublicApp tests', function() {
        var App = OCA.Sharing.PublicApp;
-       var hostStub, portStub, protocolStub, webrootStub;
+       var hostStub, protocolStub, webrootStub;
        var $preview;
 
        beforeEach(function() {
                protocolStub = sinon.stub(OC, 'getProtocol').returns('https');
-               hostStub = sinon.stub(OC, 'getHost').returns('example.com');
-               portStub = sinon.stub(OC, 'getPort').returns(9876);
+               hostStub = sinon.stub(OC, 'getHost').returns('example.com:9876');
                webrootStub = sinon.stub(OC, 'getRootPath').returns('/owncloud');
                $preview = $('<div id="preview"></div>');
                $('#testArea').append($preview);
@@ -41,7 +40,6 @@ describe('OCA.Sharing.PublicApp tests', function() {
        afterEach(function() {
                protocolStub.restore();
                hostStub.restore();
-               portStub.restore();
                webrootStub.restore();
        });
 
@@ -91,7 +89,7 @@ describe('OCA.Sharing.PublicApp tests', function() {
                it('Uses public webdav endpoint', function() {
                        expect(fakeServer.requests.length).toEqual(1);
                        expect(fakeServer.requests[0].method).toEqual('PROPFIND');
-                       expect(fakeServer.requests[0].url).toEqual('https://example.com/owncloud/public.php/webdav/subdir');
+                       expect(fakeServer.requests[0].url).toEqual('https://example.com:9876/owncloud/public.php/webdav/subdir');
                        expect(fakeServer.requests[0].requestHeaders.Authorization).toEqual('Basic c2g0dG9rOm51bGw=');
                });