diff --git a/lib/manifique/web_client.rb b/lib/manifique/web_client.rb index 6702de1..801691e 100644 --- a/lib/manifique/web_client.rb +++ b/lib/manifique/web_client.rb @@ -103,7 +103,7 @@ module Manifique icon_links.each do |link| icon = {} icon["src"] = link.attributes["href"].value rescue nil - next if icon["src"].to_s.empty? + next unless is_adequate_src(icon["src"]) icon["sizes"] = link.attributes["sizes"].value rescue nil icon["type"] = link.attributes["type"].value rescue get_icon_type(icon["src"]) @metadata.icons.push icon @@ -117,7 +117,7 @@ module Manifique icon_links.each do |link| icon = { "purpose" => "apple-touch-icon" } icon["src"] = link.attributes["href"].value rescue nil - next if icon["src"].to_s.empty? + next unless is_adequate_src(icon["src"]) icon["sizes"] = link.attributes["sizes"].value rescue nil icon["type"] = link.attributes["type"].value rescue get_icon_type(icon["src"]) @metadata.icons.push icon @@ -130,7 +130,7 @@ module Manifique if mask_icon_link = @html.at_css("link[rel=mask-icon]") icon = { "purpose" => "mask-icon" } icon["src"] = mask_icon_link.attributes["href"].value rescue nil - return if icon["src"].to_s.empty? + return unless is_adequate_src(icon["src"]) icon["type"] = link.attributes["type"].value rescue get_icon_type(icon["src"]) icon["color"] = mask_icon_link.attributes["color"].value rescue nil @metadata.icons.push icon @@ -138,6 +138,14 @@ module Manifique end end + def is_data_url?(src) + !!src.match(/^data:/) + end + + def is_adequate_src(src) + !src.to_s.empty? && !is_data_url?(src) + end + def get_icon_type(src) extension = src.match(/\.([a-zA-Z]+)$/)[1] return "image/#{extension}" @@ -161,6 +169,5 @@ module Manifique rescue false end - end end diff --git a/spec/fixtures/kommit.html b/spec/fixtures/kommit.html new file mode 100644 index 0000000..c0111fe --- /dev/null +++ b/spec/fixtures/kommit.html @@ -0,0 +1,17 @@ + + + +
+