Skip to content

Commit 86ff508

Browse files
normalizedETag
Signed-off-by: Marino Faggiana <marino.faggiana@nextcloud.com>
1 parent ef2707c commit 86ff508

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

Sources/NextcloudKit/NKCommon.swift

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,17 @@ public struct NKCommon: Sendable {
377377
return nil
378378
}
379379

380+
/// Normalizes an HTTP ETag value by removing wrapping quotes when present.
381+
/// - Parameter value: The raw ETag header value returned by the HTTP response.
382+
/// - Returns: The normalized ETag value without surrounding double quotes.
383+
public func normalizedETag(_ value: String?) -> String? {
384+
guard let value else {
385+
return nil
386+
}
387+
388+
return value.trimmingCharacters(in: CharacterSet(charactersIn: "\""))
389+
}
390+
380391
func getHostName(urlString: String) -> String? {
381392
if let url = URL(string: urlString) {
382393
guard let hostName = url.host else { return nil }

0 commit comments

Comments
 (0)