diff --git a/core/js/dist/login.js b/core/js/dist/login.js index e34bce4e2ee0eab594d8fba865b8cb6a0c01a51a..63f21659e6a37af23a520e88b136eabd410bc7ff 100644 Binary files a/core/js/dist/login.js and b/core/js/dist/login.js differ diff --git a/core/js/dist/login.js.map b/core/js/dist/login.js.map index 9f0fe02ae016be77f617aa236144843c568a1f3e..eeb046f2b16531b2bc2e0104d5582a2642f0a12c 100644 Binary files a/core/js/dist/login.js.map and b/core/js/dist/login.js.map differ diff --git a/core/js/dist/main.js b/core/js/dist/main.js index 7a235137938c40ca59b51eb2bb5c008e833f82f6..054c973f2cd174a2fb7273b34d7e5d44d39cc96a 100644 Binary files a/core/js/dist/main.js and b/core/js/dist/main.js differ diff --git a/core/js/dist/main.js.map b/core/js/dist/main.js.map index d88d07a2f9fd5bf207fe59d7fec6409f218d65b1..d9c967789e43b304c4565075f0c957de700fa915 100644 Binary files a/core/js/dist/main.js.map and b/core/js/dist/main.js.map differ diff --git a/core/js/js.js b/core/js/js.js index 7cccc66dc28ab3882982a94bd9408e0ade98ad27..40b5630e9de4f85c8bec6df530b3c88ba2c338d5 100644 --- a/core/js/js.js +++ b/core/js/js.js @@ -18,50 +18,6 @@ Object.assign(window.OC, { }, /** - * Protocol that is used to access this Nextcloud instance - * @return {string} Used protocol - */ - getProtocol: function() { - return window.location.protocol.split(':')[0]; - }, - - /** - * Returns the host used to access this Nextcloud instance - * Host is sometimes the same as the hostname but now always. - * - * Examples: - * http://example.com => example.com - * https://example.com => example.com - * http://example.com:8080 => example.com:8080 - * - * @return {string} host - * - * @since 8.2 - */ - getHost: function() { - return window.location.host; - }, - - /** - * Returns the hostname used to access this Nextcloud instance - * The hostname is always stripped of the port - * - * @return {string} hostname - * @since 9.0 - */ - getHostName: function() { - return window.location.hostname; - }, - - /** - * Returns the port number used to access this Nextcloud instance - * - * @return {int} port number - * - * @since 8.2 - */ - getPort: function() { - return window.location.port; }, /** diff --git a/core/src/OC/host.js b/core/src/OC/host.js new file mode 100644 index 0000000000000000000000000000000000000000..ac02c63a72adb19bc7f2f737e931e99fe874bf4d --- /dev/null +++ b/core/src/OC/host.js @@ -0,0 +1,63 @@ +/* + * @copyright 2019 Christoph Wurst <christoph@winzerhof-wurst.at> + * + * @author 2019 Christoph Wurst <christoph@winzerhof-wurst.at> + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +/** + * Protocol that is used to access this Nextcloud instance + * @return {string} Used protocol + * @deprecated 17.0.0 use window.location.protocol directly + */ +export const getProtocol = () => window.location.protocol.split(':')[0] + +/** + * Returns the host used to access this Nextcloud instance + * Host is sometimes the same as the hostname but now always. + * + * Examples: + * http://example.com => example.com + * https://example.com => example.com + * http://example.com:8080 => example.com:8080 + * + * @return {string} host + * + * @since 8.2 + * @deprecated 17.0.0 use window.location.host directly + */ +export const getHost = () => window.location.host + +/** + * Returns the hostname used to access this Nextcloud instance + * The hostname is always stripped of the port + * + * @return {string} hostname + * @since 9.0 + * @deprecated 17.0.0 use window.location.hostname directly + */ +export const getHostName = () => window.location.hostname + +/** + * Returns the port number used to access this Nextcloud instance + * + * @return {int} port number + * + * @since 8.2 + * @deprecated 17.0.0 use window.location.port directly + */ +export const getPort = () => window.location.port diff --git a/core/src/OC/index.js b/core/src/OC/index.js index a346c32f033f6813bec409cb634a8cc02e19a724..4525ef189aca934cb5978221526c793ba02b85ef 100644 --- a/core/src/OC/index.js +++ b/core/src/OC/index.js @@ -50,6 +50,12 @@ import Dialogs from './dialogs' import EventSource from './eventsource' import {get, set} from './get_set' import {getCapabilities} from './capabilities' +import { + getHost, + getHostName, + getPort, + getProtocol, +} from './host' import { getToken as getRequestToken, subscribe as subscribeToRequestTokenChange, @@ -157,6 +163,14 @@ export default { isSamePath, joinPaths, + /** + * Host (url) helpers + */ + getHost, + getHostName, + getPort, + getProtocol, + /** * L10n */