From a56c1bbb76673602a72f37390ecc5363692a3945 Mon Sep 17 00:00:00 2001 From: evazion Date: Fri, 4 Aug 2017 01:01:46 -0500 Subject: [PATCH] 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. --- app/models/artist.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/artist.rb b/app/models/artist.rb index fa9750f56..048abe2c3 100644 --- a/app/models/artist.rb +++ b/app/models/artist.rb @@ -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