From 54376ac58595cefc45c889fb6bce89a0cc8c629c Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Mon, 16 Dec 2024 19:10:23 -0500 Subject: [PATCH] Handle empty urls in OptionalURLDecoder Closes #553 --- .../Sources/Pachyderm/Utilities/URLDecoder.swift | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/Packages/Pachyderm/Sources/Pachyderm/Utilities/URLDecoder.swift b/Packages/Pachyderm/Sources/Pachyderm/Utilities/URLDecoder.swift index 502595fde..fff687768 100644 --- a/Packages/Pachyderm/Sources/Pachyderm/Utilities/URLDecoder.swift +++ b/Packages/Pachyderm/Sources/Pachyderm/Utilities/URLDecoder.swift @@ -63,10 +63,14 @@ public struct OptionalURLDecoder: Codable, Sendable, Hashable, ExpressibleByNilL self.wrappedValue = nil } else { let s = try container.decode(String.self) - do { - self.wrappedValue = try parseStrategy.parse(s) - } catch { - throw DecodingError.dataCorrupted(.init(codingPath: container.codingPath, debugDescription: "Could not decode URL '\(s)'", underlyingError: error)) + if s.isEmpty { + self.wrappedValue = nil + } else { + do { + self.wrappedValue = try parseStrategy.parse(s) + } catch { + throw DecodingError.dataCorrupted(.init(codingPath: container.codingPath, debugDescription: "Could not decode URL '\(s)'", underlyingError: error)) + } } } }