chore: remove deprecated hosts functions from OC

- deprecated since Nextcloud 17

- To replace `OC.getHost` use `window.location.host`.
- To replace `OC.getHostName` use `window.location.hostname`.
- To replace `OC.getPort` use `window.location.port`.
- To replace `OC.getProtocol` use `window.location.protocol`.

Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
This commit is contained in:
Ferdinand Thiessen 2025-10-29 22:57:13 +01:00
parent 9f40d4cac3
commit cf7ed089e1
No known key found for this signature in database
GPG key ID: 45FAE7268762B400
3 changed files with 5 additions and 60 deletions

View file

@ -1,42 +0,0 @@
/**
* SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
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.0
* @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.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 {number} port number
*
* @since 8.2.0
* @deprecated 17.0.0 use window.location.port directly
*/
export const getPort = () => window.location.port

View file

@ -49,12 +49,6 @@ import { currentUser, getCurrentUser } from './currentuser.js'
import { debug } from './debug.js'
import Dialogs from './dialogs.js'
import EventSource from './eventsource.js'
import {
getHost,
getHostName,
getPort,
getProtocol,
} from './host.js'
import L10N from './l10n.js'
import {
hideMenus,
@ -179,14 +173,6 @@ export default {
*/
joinPaths,
/**
* Host (url) helpers
*/
getHost,
getHostName,
getPort,
getProtocol,
/**
* @deprecated 20.0.0 use `getCanonicalLocale` from https://www.npmjs.com/package/@nextcloud/l10n
*/

View file

@ -4,6 +4,7 @@
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
import { getCurrentUser } from '@nextcloud/auth'
import escapeHTML from 'escape-html'
import $ from 'jquery'
import _ from 'underscore'
@ -958,10 +959,10 @@ import logger from '../logger.js'
}
const client = new OC.Files.Client({
host: OC.getHost(),
port: OC.getPort(),
root: OC.linkToRemoteBase('dav') + '/files/' + OC.getCurrentUser().uid,
useHTTPS: OC.getProtocol() === 'https',
host: window.location.host,
port: window.location.port,
root: OC.linkToRemoteBase('dav') + '/files/' + getCurrentUser().uid,
useHTTPS: window.location.protocol.startsWith('https'),
})
OC.Files._defaultClient = client
return client