lib/onebox/engine/standard_embed.rb in onebox-1.8.31 vs lib/onebox/engine/standard_embed.rb in onebox-1.8.32

- old
+ new

@@ -120,12 +120,15 @@ return nil unless html_doc favicon = html_doc.css('link[rel="shortcut icon"], link[rel="icon shortcut"], link[rel="shortcut"], link[rel="icon"]').first favicon = favicon.nil? ? nil : (favicon['href'].nil? ? nil : favicon['href'].strip) - if favicon && favicon.match(/^https?:\/\//i).nil? + if favicon && !!(favicon =~ /^\/\//) uri = URI(url) - favicon = uri.scheme + "://" + uri.host.sub(/\/$/, "") + "/" + favicon.sub(/^\//, "") + favicon = "#{uri.scheme}:#{favicon}" + elsif favicon && favicon.match(/^https?:\/\//i).nil? + uri = URI(url) + favicon = "#{uri.scheme}://#{uri.host.sub(/\/$/, '')}/#{favicon.sub(/^\//, '')}" end favicon end end