fix: don't crash background notification poll on an invalid instance URL

buildRequest force-unwrapped URLComponents(string:) built from the
user-entered server URL, so a value that doesn't parse as a URL crashed the
background refresh task. Guard it and return nil, matching the keychain
failure path already in this method.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
systemBlue 2026-06-02 18:40:27 -04:00
parent b0f50eca38
commit af5d50ffd3

View file

@ -87,7 +87,9 @@ final class BackgroundDownloadManager: NSObject, Sendable {
for: instance.serverURL, username: instance.username,
) else { return nil }
var components = URLComponents(string: "\(instance.serverURL)/api/v1/notifications")!
guard var components = URLComponents(string: "\(instance.serverURL)/api/v1/notifications") else {
return nil
}
components.queryItems = [
URLQueryItem(name: "status-types", value: "unread"),
URLQueryItem(name: "page", value: "1"),