Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Percent encode, URLEncodedForm using FoundationEssentials #639

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

adam-fowler
Copy link
Member

@adam-fowler adam-fowler commented Dec 24, 2024

  • Replace percentDecode function with internal one removingURLPercentEncoding from FoundationEssentials
  • Add addingPercentEncoding
  • Use in URLEncodedForm code
  • Replace ISO8601 date formatter with 6.0 Date format parser and style if available

And...

  • Breaking change: remove URLEncodedFormDecoder.DateDecodingStrategy.formatted and equivalent URLEncodedFormEncoder version. This uses DateFormatter a pre swift 6.0 type. We cannot remove our dependency on Foundation without removing this. In theory we could add a HummingbirdFoundationCompat to include this in as it can be implemented with .custom in a similar way to how JSONEncoder does it.
    public static func formatted(_ formatter: DateFormatter) -> Self {
        .custom { decoder in
            let container = try decoder.singleValueContainer()
            let result = try container.decode(String.self)
            if let date = formatter.date(from: result) {
                return date
            } else {
                throw DecodingError.dataCorrupted(DecodingError.Context(codingPath: decoder.codingPath, debugDescription: "Date string does not match format expected by formatter."))
            }
        }
    }

@adam-fowler adam-fowler requested a review from Joannis as a code owner December 24, 2024 11:40
Copy link

github-actions bot commented Dec 24, 2024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant