0
0
Fork 0

Fix Nokogiri::HTML at FetchLinkCardService (#4072)

This commit is contained in:
abcang 2017-07-05 21:54:21 +09:00 committed by Eugen Rochko
parent b52a5e6bd6
commit 5e6acf9601
3 changed files with 33 additions and 1 deletions

View file

@ -1,4 +1,5 @@
# frozen_string_literal: true
require 'nkf'
class FetchLinkCardService < BaseService
include HttpHelper
@ -84,7 +85,8 @@ class FetchLinkCardService < BaseService
return if response.code != 200 || response.mime_type != 'text/html'
page = Nokogiri::HTML(response.to_s)
html = response.to_s
page = Nokogiri::HTML(html, nil, NKF.guess(html).to_s)
card.type = :link
card.title = meta_property(page, 'og:title') || page.at_xpath('//title')&.content