From ab1d786d879d519c86cd2016490d1ade5e43fd41 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Thomas=20M=C3=BCller?= <thomas.mueller@tmit.eu>
Date: Tue, 17 Nov 2015 13:37:13 +0100
Subject: [PATCH] Fix port issue - options.host already has the port attached

---
 apps/files_sharing/tests/js/publicAppSpec.js |  6 ++----
 core/js/files/client.js                      | 19 +++----------------
 core/js/tests/specs/files/clientSpec.js      |  3 +--
 3 files changed, 6 insertions(+), 22 deletions(-)

diff --git a/apps/files_sharing/tests/js/publicAppSpec.js b/apps/files_sharing/tests/js/publicAppSpec.js
index 8a644232e6..1ea5f7ed1b 100644
--- a/apps/files_sharing/tests/js/publicAppSpec.js
+++ b/apps/files_sharing/tests/js/publicAppSpec.js
@@ -21,13 +21,12 @@
 
 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(8080);
 		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://sh4tok@example.com:8080/owncloud/public.php/webdav/subdir');
+			expect(fakeServer.requests[0].url).toEqual('https://sh4tok@example.com/owncloud/public.php/webdav/subdir');
 		});
 
 		describe('Download Url', function() {
diff --git a/core/js/files/client.js b/core/js/files/client.js
index 5ee90d2d52..07a7132d4b 100644
--- a/core/js/files/client.js
+++ b/core/js/files/client.js
@@ -31,22 +31,9 @@
 			this._root = this._root.substr(0, this._root.length - 1);
 		}
 
-		if (!options.port) {
-			// workaround in case port is null or empty
-			options.port = undefined;
-		}
-		var url = '';
-		var port = '';
+		var url = 'http://';
 		if (options.useHTTPS) {
-			url += 'https://';
-			if (options.port && options.port !== 443) {
-				port = ':' + options.port;
-			}
-		} else {
-			url += 'http://';
-			if (options.port && options.port !== 80) {
-				port = ':' + options.port;
-			}
+			url = 'https://';
 		}
 		var credentials = '';
 		if (options.userName) {
@@ -59,7 +46,7 @@
 			url += credentials + '@';
 		}
 
-		url += options.host + port + this._root;
+		url += options.host + this._root;
 		this._defaultHeaders = options.defaultHeaders || {'X-Requested-With': 'XMLHttpRequest'};
 		this._baseUrl = url;
 		this._client = new dav.Client({
diff --git a/core/js/tests/specs/files/clientSpec.js b/core/js/tests/specs/files/clientSpec.js
index 67815d93f0..7d039b5143 100644
--- a/core/js/tests/specs/files/clientSpec.js
+++ b/core/js/tests/specs/files/clientSpec.js
@@ -25,11 +25,10 @@ describe('OC.Files.Client tests', function() {
 	var client;
 
 	beforeEach(function() {
-		baseUrl = 'https://testhost:999/owncloud/remote.php/webdav/';
+		baseUrl = 'https://testhost/owncloud/remote.php/webdav/';
 
 		client = new Client({
 			host: 'testhost',
-			port: 999,
 			root: '/owncloud/remote.php/webdav',
 			useHTTPS: true
 		});
-- 
GitLab