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

Merged
merged 10 commits into from
Jan 13, 2025

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

@Joannis
Copy link
Member

Joannis commented Dec 26, 2024

Assuming this doesn't break older Apple OS'es, LGTM

@adam-fowler adam-fowler added the breaking change Change that requires a major version label Dec 28, 2024
@adam-fowler
Copy link
Member Author

I've removed the breaking change, because I think it needs more discussion

@adam-fowler adam-fowler removed the breaking change Change that requires a major version label Jan 13, 2025
@adam-fowler adam-fowler merged commit f7a769b into main Jan 13, 2025
7 checks passed
@adam-fowler adam-fowler deleted the percent-encode branch January 13, 2025 10:48
bcbod2002 pushed a commit to bcbod2002/hummingbird that referenced this pull request Feb 6, 2025
…d-project#639)

* Add percentEncode/Decode from Foundation Essentials

* Use percent encoding in URLEncodedForms

* Use new percent encode/decode functions

* Use Swift 6.0 ISO8601 format parser/style if available

* Add NOTICE.txt

* Remove URLEncoded DateDecodingStrategy.formatted

* import FoundationEssentials in URLEncodedForm code

* Copyright header

* Remove breaking change
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.

2 participants