#1866: Support dA urls without artist name in them

This commit is contained in:
Toks
2013-12-24 16:40:57 -05:00
parent 52fd58087d
commit 4ddf8d5eab
2 changed files with 5 additions and 0 deletions

View File

@@ -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}"

View File

@@ -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