Skip to content

Commit 42ccc3e

Browse files
committed
Fix crash
1 parent 6bab7eb commit 42ccc3e

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

Sources/LyricsService/Provider/Services/Spotify.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,11 @@ extension LyricsProviders.Spotify: _LyricsProvider {
2626
let url: URL
2727
switch request.searchTerm {
2828
case .keyword(let string):
29-
url = URL(string: "https://api.spotify.com/v1/search?q=track:\(string)&type=track&limit=\(request.limit)")!
29+
guard let _url = URL(string: "https://api.spotify.com/v1/search?q=track:\(string)&type=track&limit=\(request.limit)") else { return [] }
30+
url = _url
3031
case .info(let title, let artist):
31-
url = URL(string: "https://api.spotify.com/v1/search?q=track:\(title) artist:\(artist)&type=track&limit=\(request.limit)")!
32+
guard let _url = URL(string: "https://api.spotify.com/v1/search?q=track:\(title) artist:\(artist)&type=track&limit=\(request.limit)") else { return [] }
33+
url = _url
3234
}
3335

3436
var req = URLRequest(url: url)

0 commit comments

Comments
 (0)