Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
erwanlr committed Dec 11, 2017
1 parent 859d7f1 commit 54c0e79
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/common/models/wp_theme/findable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def find_from_css_link(target_uri)
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,
Expand Down
15 changes: 12 additions & 3 deletions spec/lib/common/models/wp_theme/findable_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,18 @@

# 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

Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<html><head><title>Test</title><link rel="stylesheet" type="text/css" href="/wp-content/themes/theme_name/style.css" /></head><body></body></html>
<html><head><title>Test</title><link rel="stylesheet" type="text/css" href="/wp-content/themes/theme_name/style.css" /></head><body></body></html>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<html><head><title>Test</title><link rel="stylesheet" type="text/css" href="wp-content/themes/theme_name/style.css" /></head><body></body></html>

0 comments on commit 54c0e79

Please sign in to comment.