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

URL construction fails with umlauts in string #2280

Closed
Arestronaut opened this issue May 24, 2022 · 2 comments
Closed

URL construction fails with umlauts in string #2280

Arestronaut opened this issue May 24, 2022 · 2 comments
Labels
bug Generally incorrect behavior

Comments

@Arestronaut
Copy link

Bug report

When receiving a url string from the server containing special characters like umlauts ü, ä the URL initialisation fails and therefore the decoding.

let urlString = "https://zürich.ch/"
guard let url = URL(string: urlString) else {
    fatalError("Could not construct URL")
}

print(url)

Will producte Fatal error: Could not construct URL

This can easily be fixed using addingPercentageEncoding

let urlString = "https://zürich.ch/"
let sanitizedURLString = urlString.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed)

guard let sanitizedURLString = sanitizedURLString, let url = URL(string: sanitizedURLString) else {
    fatalError("Could not construct URL")
}

print(url)

Will produce https://z%C3%BCrich.ch/

Versions

Please fill in the versions you're currently using:

  • apollo-ios SDK version: 0.50.0
  • Xcode version: 13.4
  • Swift version: 5.5
  • Package manager: SPM
@calvincestari
Copy link
Member

Thanks for the bug report @Arestronaut. Is this specifically a problem only when receiving URLs from the server or also if you try connect to a URL with special characters in it?

@jpvajda jpvajda added the bug Generally incorrect behavior label Jun 28, 2022
@AnthonyMDev AnthonyMDev closed this as not planned Won't fix, can't repro, duplicate, stale May 17, 2024
Copy link

Do you have any feedback for the maintainers? Please tell us by taking a one-minute survey. Your responses will help us understand Apollo iOS usage and allow us to serve you better.

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

No branches or pull requests

4 participants