diff --git a/Sources/Services/ContainerAPIService/Client/Utility.swift b/Sources/Services/ContainerAPIService/Client/Utility.swift index 4d0ba700a..3f44fbb20 100644 --- a/Sources/Services/ContainerAPIService/Client/Utility.swift +++ b/Sources/Services/ContainerAPIService/Client/Utility.swift @@ -348,7 +348,7 @@ public struct Utility { public static func parseKeyValuePairs(_ pairs: [String]) -> [String: String] { var result: [String: String] = Dictionary(minimumCapacity: pairs.count) for pair in pairs { - let components = pair.split(separator: "=", maxSplits: 1) + let components = pair.split(separator: "=", maxSplits: 1, omittingEmptySubsequences: false) if components.count == 2 { result[String(components[0])] = String(components[1]) } else { diff --git a/Tests/ContainerAPIClientTests/UtilityTests.swift b/Tests/ContainerAPIClientTests/UtilityTests.swift index 3a9b3a495..d1df02689 100644 --- a/Tests/ContainerAPIClientTests/UtilityTests.swift +++ b/Tests/ContainerAPIClientTests/UtilityTests.swift @@ -38,6 +38,14 @@ struct UtilityTests { #expect(result["standalone"] == "") } + @Test("Parse key with an explicitly empty value") + func testKeyWithEmptyValue() { + let result = Utility.parseKeyValuePairs(["owner="]) + + #expect(result["owner"] == "") + #expect(result["owner="] == nil) + } + @Test("Parse empty input") func testEmptyInput() { let result = Utility.parseKeyValuePairs([])