FIX: Old `Upload#url` scheme support for `Upload.get_from_url`.

FIX: Old Upload#url scheme support for Upload.get_from_url.

This is for backwards compatibility purposes. Even if Upload#url has a format that we don’t recognize, we should still return the upload object as long as the upload record is present.

diff --git a/app/models/concerns/has_url.rb b/app/models/concerns/has_url.rb
index 5fdc4b2..7fcf82f 100644
--- a/app/models/concerns/has_url.rb
+++ b/app/models/concerns/has_url.rb
@@ -26,7 +26,13 @@ module HasUrl
 
       return if uri&.path.blank?
       data = extract_url(uri.path)
-      return if data.blank?
+
+      if data.blank?
+        result = nil
+        result ||= self.find_by(url: uri.path)
+        return result
+      end
+
       result = nil
 
       if self.name == "Upload"
diff --git a/spec/models/upload_spec.rb b/spec/models/upload_spec.rb
index 0cc49e6..2fb9be2 100644
--- a/spec/models/upload_spec.rb
+++ b/spec/models/upload_spec.rb
@@ -122,6 +122,12 @@ describe Upload do
       end
     end
 
+    it "should return the right upload as long as the upload's URL matches" do
+      upload.update!(url: "/uploads/default/12345/971308e535305c51.png")
+
+      expect(Upload.get_from_url(upload.url)).to eq(upload)
+    end
+
     describe 'for a url a tree' do
       before do
         upload.update!(url:

GitHub sha: a8baa6d9

DEV: Improve `Upload.get_from_url` test case.