Skip to content

Conversation

@BakJakub
Copy link

@BakJakub BakJakub commented Apr 14, 2024

When building GET addresses, double decoding takes place, which is an error, so I used the extension method, you can also add an example of how to decode only single cases in getURLWithParams

                if let query = urlComponents.percentEncodedQuery {
                    urlComponents.percentEncodedQuery = query
                        .replacingOccurrences(of: "!", with: "%21")
                        .replacingOccurrences(of: "$", with: "%24")
                        .replacingOccurrences(of: "'", with: "%27")
                        .replacingOccurrences(of: "(", with: "%28")
                        .replacingOccurrences(of: ")", with: "%29")
                        .replacingOccurrences(of: "*", with: "%2A")
                        .replacingOccurrences(of: "+", with: "%2B")
                        .replacingOccurrences(of: ",", with: "%2C")
                        .replacingOccurrences(of: ";", with: "%3B")
                        .replacingOccurrences(of: ":", with: "%3A")
                        .replacingOccurrences(of: "#", with: "%23")
                        .replacingOccurrences(of: "[", with: "%5B")
                        .replacingOccurrences(of: "]", with: "%5D")
                        .replacingOccurrences(of: "@", with: "%40")
                }

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