forked from shadowfacts/Tusker
Fix pagination links not being parsed correctly for some URLs
Fixes an issue where Mentions notifications wouldn't load past the first page. URLComponents(string:) fails when the string contains some characters, such as [ or ] URL(string:) and then URLComponents(url:resolvingAgainstBaseURL:) does not fail See FB7271340
This commit is contained in:
parent
84a07fc718
commit
60aa6eca36
|
@ -44,13 +44,16 @@ extension Pagination {
|
||||||
}
|
}
|
||||||
let rel = segments.last?.replacingOccurrences(of: "\"", with: "").trimmingCharacters(in: .whitespaces).components(separatedBy: "=")
|
let rel = segments.last?.replacingOccurrences(of: "\"", with: "").trimmingCharacters(in: .whitespaces).components(separatedBy: "=")
|
||||||
|
|
||||||
guard let validURL = url,
|
guard let urlStr = url,
|
||||||
|
let validURL = URL(string: urlStr),
|
||||||
let key = rel?.first,
|
let key = rel?.first,
|
||||||
key == "rel",
|
key == "rel",
|
||||||
let value = rel?.last,
|
let value = rel?.last,
|
||||||
let kind = Kind(rawValue: value),
|
let kind = Kind(rawValue: value),
|
||||||
let components = URLComponents(string: validURL),
|
let components = URLComponents(url: validURL, resolvingAgainstBaseURL: false),
|
||||||
let queryItems = components.queryItems else { return nil }
|
let queryItems = components.queryItems else {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
let min = queryItems.first { $0.name == "min_id" }?.value
|
let min = queryItems.first { $0.name == "min_id" }?.value
|
||||||
let since = queryItems.first { $0.name == "since_id" }?.value
|
let since = queryItems.first { $0.name == "since_id" }?.value
|
||||||
|
|
Loading…
Reference in New Issue