|
| 1 | +// SPDX-FileCopyrightText: Nextcloud GmbH |
| 2 | +// SPDX-FileCopyrightText: 2026 Marino Faggiana |
| 3 | +// SPDX-License-Identifier: GPL-3.0-or-later |
| 4 | + |
| 5 | +/// Utility namespace for constructing Nextcloud WebDAV (DAV) endpoint paths. |
| 6 | +/// |
| 7 | +/// The standard DAV structure in Nextcloud is: |
| 8 | +/// `<baseURL>/remote.php/dav/files/<userId>/` |
| 9 | +public enum NKDav { |
| 10 | + |
| 11 | + // Base DAV endpoint used by Nextcloud |
| 12 | + public static let basePath = "/remote.php/dav/" |
| 13 | + |
| 14 | + // Files namespace within DAV |
| 15 | + public static let filesPath = "files/" |
| 16 | + |
| 17 | + /// Builds the user DAV path with trailing slash |
| 18 | + /// Example: /remote.php/dav/files/<userId>/ |
| 19 | + public static func userPath(userId: String) -> String { |
| 20 | + basePath + filesPath + userId + "/" |
| 21 | + } |
| 22 | + |
| 23 | + /// Builds the user DAV path without trailing slash |
| 24 | + /// Example: /remote.php/dav/files/<userId> |
| 25 | + public static func userPathNoSlash(userId: String) -> String { |
| 26 | + basePath + filesPath + userId |
| 27 | + } |
| 28 | + |
| 29 | + /// Full DAV URL (with trailing slash) |
| 30 | + public static func homeURLString(urlBase: String, userId: String) -> String { |
| 31 | + urlBase + userPath(userId: userId) |
| 32 | + } |
| 33 | + |
| 34 | + /// Full DAV URL (without trailing slash) |
| 35 | + public static func homeURLStringNoSlash(urlBase: String, userId: String) -> String { |
| 36 | + urlBase + userPathNoSlash(userId: userId) |
| 37 | + } |
| 38 | +} |
0 commit comments