Simplified encoding query

This commit is contained in:
ByteHamster 2019-07-12 15:28:33 +02:00
parent 3962fdd6f8
commit cbf3a2102f
1 changed files with 2 additions and 4 deletions

View File

@ -31,14 +31,12 @@ public class ItunesPodcastSearcher implements PodcastSearcher {
public Single<List<PodcastSearchResult>> search(String query) { public Single<List<PodcastSearchResult>> search(String query) {
return Single.create((SingleOnSubscribe<List<PodcastSearchResult>>) subscriber -> { return Single.create((SingleOnSubscribe<List<PodcastSearchResult>>) subscriber -> {
String encodedQuery = null; String encodedQuery;
try { try {
encodedQuery = URLEncoder.encode(query, "UTF-8"); encodedQuery = URLEncoder.encode(query, "UTF-8");
} catch (UnsupportedEncodingException e) { } catch (UnsupportedEncodingException e) {
// this won't ever be thrown // this won't ever be thrown
} encodedQuery = query;
if (encodedQuery == null) {
encodedQuery = query; // failsafe
} }
String formattedUrl = String.format(ITUNES_API_URL, encodedQuery); String formattedUrl = String.format(ITUNES_API_URL, encodedQuery);