Fix loading attachments from Pleroma

Unlike Mastodon, Pleroma includes a URL query component in attachment URLs.
The URL(lenient:) initializer did not count query parameters (e.g. '?') as valid URL characters
and incorrectly escaped them resulting in image requests that 404'd.
This commit is contained in:
Shadowfacts 2019-06-13 23:48:21 -07:00
parent 940ba6d6cb
commit 8a45837918
Signed by untrusted user: shadowfacts
GPG Key ID: 83FB3304046BADA4
1 changed files with 1 additions and 1 deletions

View File

@ -115,7 +115,7 @@ extension Attachment {
}
fileprivate extension URL {
private static let allowedChars = CharacterSet.urlHostAllowed.union(.urlPathAllowed)
private static let allowedChars = CharacterSet.urlHostAllowed.union(.urlPathAllowed).union(.urlQueryAllowed)
init?(lenient string: String) {
guard let escaped = string.addingPercentEncoding(withAllowedCharacters: URL.allowedChars) else {