artists: fix validation error when url_string has leading spaces.

Bug: if the url_string had leading spaces, when it was split the
resulting array contained the empty string, which led to a validation
error when trying to save the urls.

Fixup for #3247.
This commit is contained in:
evazion
2017-08-04 01:01:46 -05:00
parent e2c2435356
commit a56c1bbb76

View File

@@ -67,7 +67,7 @@ class Artist < ApplicationRecord
def url_string=(string)
@url_string_was = url_string
self.urls = string.split(/[[:space:]]+/).uniq.map do |url|
self.urls = string.scan(/[^[:space:]]+/).uniq.map do |url|
self.urls.find_or_initialize_by(url: url)
end
end