diff --git a/lib/common/models/wp_theme/findable.rb b/lib/common/models/wp_theme/findable.rb index 68770bb1..97451689 100644 --- a/lib/common/models/wp_theme/findable.rb +++ b/lib/common/models/wp_theme/findable.rb @@ -30,7 +30,7 @@ class WpTheme < WpItem response = Browser.get_and_follow_location(target_uri.to_s) # https + domain is optional because of relative links - return unless response.body =~ %r{(?:https?://[^"']+/)?([^/\s]+)/themes/([^"'/]+)[^"']*/style.css}i + return unless response.body =~ %r{(?:https?://[^"']+/)?([^"'/\s]+)/themes/([^"'/]+)[^"']*/style\.css}i new( target_uri, diff --git a/spec/lib/common/models/wp_theme/findable_spec.rb b/spec/lib/common/models/wp_theme/findable_spec.rb index 531b2c4d..7251c477 100644 --- a/spec/lib/common/models/wp_theme/findable_spec.rb +++ b/spec/lib/common/models/wp_theme/findable_spec.rb @@ -45,9 +45,18 @@ describe 'WpTheme::Findable' do # FIXME: the style_url should be checked in WpTheme for absolute / relative context 'when relative url is used' do - it 'returns the WpTheme' do - @file = 'relative_urls.html' - @expected = WpTheme.new(uri, name: 'theme_name') + context 'when leading slash' do + it 'returns the WpTheme' do + @file = 'relative_urls.html' + @expected = WpTheme.new(uri, name: 'theme_name') + end + end + + context 'when no leading slash' do + it 'returns the WpTheme' do + @file = 'relative_urls_missing_slash.html' + @expected = WpTheme.new(uri, name: 'theme_name') + end end end diff --git a/spec/samples/common/models/wp_theme/findable/css_link/relative_urls.html b/spec/samples/common/models/wp_theme/findable/css_link/relative_urls.html index f494bc2d..da4b65bf 100644 --- a/spec/samples/common/models/wp_theme/findable/css_link/relative_urls.html +++ b/spec/samples/common/models/wp_theme/findable/css_link/relative_urls.html @@ -1 +1 @@ -