From 4ddf8d5eab8c9d6e003215f8469bb16259c1ab9f Mon Sep 17 00:00:00 2001 From: Toks Date: Tue, 24 Dec 2013 16:40:57 -0500 Subject: [PATCH] #1866: Support dA urls without artist name in them --- app/models/post.rb | 3 +++ test/unit/post_test.rb | 2 ++ 2 files changed, 5 insertions(+) diff --git a/app/models/post.rb b/app/models/post.rb index a16c963e4..a7e91eca4 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -304,6 +304,9 @@ class Post < ActiveRecord::Base when %r{\Ahttp://(?:fc|th)\d{2}\.deviantart\.net/.+/[a-z0-9_]+_by_([a-z0-9_]+)-d([a-z0-9]+)\.}i "http://#{$1}.deviantart.com/gallery/#/d#{$2}" + when %r{\Ahttp://(?:fc|th)\d{2}\.deviantart\.net/.+/[a-f0-9]+-d([a-z0-9]+)\.}i + "http://deviantart.com/gallery/#/d#{$1}" + when %r{\Ahttp://www\.karabako\.net/images(?:ub)?/karabako_(\d+)(?:_\d+)?\.}i "http://www.karabako.net/post/view/#{$1}" diff --git a/test/unit/post_test.rb b/test/unit/post_test.rb index bc1c478bc..8b6f8f8de 100644 --- a/test/unit/post_test.rb +++ b/test/unit/post_test.rb @@ -836,6 +836,8 @@ class PostTest < ActiveSupport::TestCase should "normalize deviantart links" do @post.source = "http://fc06.deviantart.net/fs71/f/2013/295/d/7/you_are_already_dead__by_mar11co-d6rgm0e.jpg" assert_equal("http://mar11co.deviantart.com/gallery/#/d6rgm0e", @post.normalized_source) + @post.source = "http://fc00.deviantart.net/fs71/f/2013/337/3/5/35081351f62b432f84eaeddeb4693caf-d6wlrqs.jpg" + assert_equal("http://deviantart.com/gallery/#/d6wlrqs", @post.normalized_source) end should "normalize karabako links" do