Skip to content

Commit 081cd91

Browse files
committed
Added guard statements for empty share tokens.
Relates to nextcloud/ios#3383 Signed-off-by: Iva Horn <iva.horn@icloud.com>
1 parent a022573 commit 081cd91

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

Sources/NextcloudKit/NextcloudKit+ShareDownloadLimit.swift

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ public extension NextcloudKit {
1212
}
1313

1414
func getDownloadLimit(account: String, token: String, completion: @escaping (NKDownloadLimit?, NKError) -> Void) {
15+
guard token.isEmpty == false else {
16+
self.nkCommonInstance.writeLog("[ERROR] Attempt to get share download limit with empty token!")
17+
return
18+
}
19+
1520
let endpoint = makeEndpoint(with: token)
1621
let options = NKRequestOptions()
1722

@@ -81,6 +86,11 @@ public extension NextcloudKit {
8186
}
8287

8388
func removeShareDownloadLimit(account: String, token: String, completion: @escaping (_ error: NKError) -> Void) {
89+
guard token.isEmpty == false else {
90+
self.nkCommonInstance.writeLog("[ERROR] Attempt to remove share download limit with empty token!")
91+
return
92+
}
93+
8494
let endpoint = makeEndpoint(with: token)
8595
let options = NKRequestOptions()
8696

@@ -117,6 +127,11 @@ public extension NextcloudKit {
117127
}
118128

119129
func setShareDownloadLimit(account: String, token: String, limit: Int, completion: @escaping (_ error: NKError) -> Void) {
130+
guard token.isEmpty == false else {
131+
self.nkCommonInstance.writeLog("[ERROR] Attempt to set share download limit with empty token!")
132+
return
133+
}
134+
120135
let endpoint = makeEndpoint(with: token)
121136
let options = NKRequestOptions()
122137
options.contentType = "application/json"

0 commit comments

Comments
 (0)