Skip to content

Commit

Permalink
Get url from html document parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
huyha85 committed Dec 22, 2021
1 parent 6b844da commit 1984289
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
6 changes: 4 additions & 2 deletions lib/open_graph.rb
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,11 @@ def load_fallback

def check_images_path
@original_images = @images.dup
return if @html_content

uri = Addressable::URI.parse(@src)
uri = Addressable::URI.parse(@url || @src)

return unless uri

imgs = @images.dup
@images = []
imgs.each do |img|
Expand Down
2 changes: 1 addition & 1 deletion spec/lib/open_graph_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@
og.type.should == "article"
og.url.should == "http://test.host"
og.description.should == "My OpenGraph sample site for Rspec"
og.images.should == ["http://test.host/images/rock1.jpg", "/images/rock2.jpg"]
og.images.should == ["http://test.host/images/rock1.jpg", "http://test.host/images/rock2.jpg"]
end
end
end
Expand Down
8 changes: 7 additions & 1 deletion spec/view/opengraph.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
<!--
===================================================================
=============================== https://github.com/huyha85 ===
===================================================================
-->

<html>
<head>
<title>OpenGraph Title Fallback</title>
Expand All @@ -19,4 +25,4 @@
<img src="http://test.host/images/wall1.jpg" />
<img src="http://test.host/images/wall2.jpg" />
</body>
</html>
</html>

0 comments on commit 1984289

Please sign in to comment.