From 0cba44e3bf37f557fade61f9a6ebbc7750d710b0 Mon Sep 17 00:00:00 2001 From: Toks Date: Mon, 28 Apr 2014 15:45:11 -0400 Subject: [PATCH] Fix deviantart regex bugs --- app/logical/downloads/strategies/deviant_art.rb | 8 ++++---- app/logical/sources/strategies/deviant_art.rb | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/logical/downloads/strategies/deviant_art.rb b/app/logical/downloads/strategies/deviant_art.rb index 683f5ca9d..45e939faf 100644 --- a/app/logical/downloads/strategies/deviant_art.rb +++ b/app/logical/downloads/strategies/deviant_art.rb @@ -2,7 +2,7 @@ module Downloads module Strategies class DeviantArt < Base def rewrite(url, headers) - if url =~ /https?:\/\/(?:\w+\.)?deviantart\.(?:com|net)/ + if url =~ /https?:\/\/(?:.+?\.)?deviantart\.(?:com|net)/ url, headers = rewrite_html_pages(url, headers) url, headers = rewrite_thumbnails(url, headers) end @@ -12,7 +12,7 @@ module Downloads protected def rewrite_html_pages(url, headers) - if url =~ %r{^http://\w+\.deviantart\.com/art/\w+} + if url =~ %r{^http://.+?\.deviantart\.com/art/} source = ::Sources::Strategies::DeviantArt.new(url) source.get return [source.image_url, headers] @@ -22,10 +22,10 @@ module Downloads end def rewrite_thumbnails(url, headers) - if url =~ %r{^(http://\w+.deviantart.net/\w+/)200H/} + if url =~ %r{^(http://.+?\.deviantart\.net/.+?/)200H/} match = $1 url.sub!(match + "200H/", match) - elsif url =~ %r{^(http://\w+.deviantart.net/\w+/)PRE/} + elsif url =~ %r{^(http://.+?\.deviantart\.net/.+?/)PRE/} match = $1 url.sub!(match + "PRE/", match) end diff --git a/app/logical/sources/strategies/deviant_art.rb b/app/logical/sources/strategies/deviant_art.rb index 0b0875e5c..6588b5090 100644 --- a/app/logical/sources/strategies/deviant_art.rb +++ b/app/logical/sources/strategies/deviant_art.rb @@ -2,7 +2,7 @@ module Sources module Strategies class DeviantArt < Base def self.url_match?(url) - url =~ /^https?:\/\/(?:\w+\.)?deviantart\.(?:com|net)/ + url =~ /^https?:\/\/(?:.+?\.)?deviantart\.(?:com|net)/ end def site_name @@ -10,7 +10,7 @@ module Sources end def unique_id - profile_url =~ /https?:\/\/(\w+)\.deviantart\.com/ + profile_url =~ /https?:\/\/(.+?)\.deviantart\.com/ "deviantart" + $1 end