Networking icon indicating copy to clipboard operation
Networking copied to clipboard

Fixed the double encoding problem and used a method from Params Extensions

Open BakJakub opened this issue 1 year ago • 0 comments

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")
                }

BakJakub avatar Apr 14 '24 23:04 BakJakub