Browse Source

fix code

Signed-off-by: marinofaggiana <ios@nextcloud.com>
marinofaggiana 2 years ago
parent
commit
cd8d818af7
1 changed files with 4 additions and 2 deletions
  1. 4 2
      iOSClient/Utility/NCUtilityFileSystem.swift

+ 4 - 2
iOSClient/Utility/NCUtilityFileSystem.swift

@@ -174,8 +174,10 @@ class NCUtilityFileSystem: NSObject {
 
     @objc func deletingLastPathComponent(account: String, serverUrl: String) -> String {
 
-        guard getHomeServer(account: account) != serverUrl, let url = URL(string: serverUrl) else { return serverUrl }
-        return String(url.deletingLastPathComponent().absoluteString.dropLast())
+        if getHomeServer(account: account) == serverUrl { return serverUrl }
+        let fileName = (serverUrl as NSString).lastPathComponent
+        let serverUrl = serverUrl.replacingOccurrences(of: "/" + fileName, with: "", options: String.CompareOptions.backwards, range: nil)
+        return serverUrl
     }
 
     @objc func createFileName(_ fileName: String, serverUrl: String, account: String) -> String {