From 03d2098d6d275f105b62f25b93622c0e9a3f8d0c Mon Sep 17 00:00:00 2001 From: evazion Date: Fri, 18 Mar 2022 05:54:44 -0500 Subject: [PATCH] artists: fix artist finder returning wrong results when given nil url. Fix the artist finder returning incorrect results when given a nil URL. This only happened when an artist with a URL like this existed: http:///blog.naver.com/dan_rak Note the triple `///`; the extra `/` messed up the artist finder. The artist finder may be given a nil URL when a source strategy returns a nil profile URL, usually because the source is bad_id. --- app/logical/artist_finder.rb | 2 ++ app/logical/sources/strategies/base.rb | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/app/logical/artist_finder.rb b/app/logical/artist_finder.rb index 902158f27..8e89d7b30 100644 --- a/app/logical/artist_finder.rb +++ b/app/logical/artist_finder.rb @@ -154,6 +154,8 @@ module ArtistFinder # @param url [String] the artist profile URL # @return [Array] the list of matching artists def find_artists(url) + return Artist.none if url.blank? + url = ArtistURL.normalize_normalized_url(url) # First try an exact match diff --git a/app/logical/sources/strategies/base.rb b/app/logical/sources/strategies/base.rb index 2fdda17d9..6768d3103 100644 --- a/app/logical/sources/strategies/base.rb +++ b/app/logical/sources/strategies/base.rb @@ -145,7 +145,7 @@ module Sources end def artists - ArtistFinder.find_artists(profile_url.to_s) + ArtistFinder.find_artists(profile_url) end # A new artist entry with suggested defaults for when the artist doesn't