From 47f56cd19dc052973989009ebc82eae239d7af2b Mon Sep 17 00:00:00 2001 From: Toks Date: Sun, 4 May 2014 15:54:11 -0400 Subject: [PATCH] #1866: Fix deviantart regex again and support alternate url style --- app/logical/sources/strategies/deviant_art.rb | 4 +++- app/models/post.rb | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/logical/sources/strategies/deviant_art.rb b/app/logical/sources/strategies/deviant_art.rb index 6588b5090..11a463282 100644 --- a/app/logical/sources/strategies/deviant_art.rb +++ b/app/logical/sources/strategies/deviant_art.rb @@ -50,7 +50,9 @@ module Sources def normalized_url @normalized_url ||= begin - if url =~ %r{\Ahttp://(?:fc|th)\d{2}\.deviantart\.net/.+/[a-z0-9_]+_by_[a-z0-9_]+-d([a-z0-9]+)\.}i + if url =~ %r{\Ahttp://(?:fc|th)\d{2}\.deviantart\.net/.+/[a-z0-9_]*_by_[a-z0-9_]+-d([a-z0-9]+)\.}i + "http://fav.me/d#{$1}" + elsif url =~ %r{\Ahttp://(?:fc|th)\d{2}\.deviantart\.net/.+/[a-f0-9]+-d([a-z0-9]+)\.}i "http://fav.me/d#{$1}" elsif url =~ %r{deviantart\.com/art/} url diff --git a/app/models/post.rb b/app/models/post.rb index 66f454399..41b29cdbe 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -287,7 +287,7 @@ 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 + 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