Fix #4720: Pixiv commentary links all create invalid urls.
Regression caused by the switch from the mobile API to the Ajax API. In the Ajax API, commentaries have /jump.php?<url> links that we have to strip out.
This commit is contained in:
@@ -66,12 +66,17 @@ module Sources
|
||||
text = text.gsub(%r{<a href="https?://www\.pixiv\.net/en/users/([0-9]+)">user/[0-9]+</a>}i) do |_match|
|
||||
member_id = $1
|
||||
profile_url = "https://www.pixiv.net/users/#{member_id}"
|
||||
|
||||
artist_search_url = Routes.artists_path(search: { url_matches: profile_url })
|
||||
|
||||
%("user/#{member_id}":[#{profile_url}] "»":[#{artist_search_url}])
|
||||
end
|
||||
|
||||
DText.from_html(text)
|
||||
DText.from_html(text) do |element|
|
||||
if element.name == "a" && element["href"].match?(%r!\A/jump\.php\?!)
|
||||
element["href"] = Addressable::URI.heuristic_parse(element["href"]).normalized_query
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def domains
|
||||
|
||||
@@ -196,6 +196,21 @@ module Sources
|
||||
dtext_desc = %(foo 【[b]pixiv #46337015 "»":[/posts?tags=pixiv%3A46337015][/b]】bar 【[b]pixiv #14901720 "»":[/posts?tags=pixiv%3A14901720][/b]】\n\nbaz【[b]"user/83739":[https://www.pixiv.net/users/83739] "»":[/artists?search%5Burl_matches%5D=https%3A%2F%2Fwww.pixiv.net%2Fusers%2F83739][/b]】)
|
||||
assert_equal(dtext_desc, @site.dtext_artist_commentary_desc)
|
||||
end
|
||||
|
||||
should "convert jump.php links" do
|
||||
get_source("https://www.pixiv.net/en/artworks/68955584")
|
||||
|
||||
dtext_desc = <<~EOS
|
||||
東方や版権中心にまとめました
|
||||
|
||||
◆例大祭の新刊([b]pixiv #68490887 "»":[/posts?tags=pixiv%3A68490887][/b])を一部加筆して再版しました。通販在庫復活しているのでよろしければ▷<https://www.melonbooks.co.jp/detail/detail.php?product_id=364421>
|
||||
今週末京都みやこめっせで開催される「古明地こんぷれっくす いつつめ」にも持っていきます〜。スペースは【古13】です。他にも色々持って行く予定なので、改めて告知します。
|
||||
|
||||
◇pixivFANBOX開設してみました。のんびり投稿していく予定です(:˒[ ̄]メイキングとかやってみたい…▶︎<https://www.pixiv.net/fanbox/creator/143555>
|
||||
EOS
|
||||
|
||||
assert_equal(dtext_desc.chomp, @site.dtext_artist_commentary_desc)
|
||||
end
|
||||
end
|
||||
|
||||
context "translating the tags" do
|
||||
|
||||
Reference in New Issue
Block a user