diff --git a/app/logical/sources/strategies/pixiv.rb b/app/logical/sources/strategies/pixiv.rb
index 0a670351d..10e5e7e69 100644
--- a/app/logical/sources/strategies/pixiv.rb
+++ b/app/logical/sources/strategies/pixiv.rb
@@ -66,12 +66,17 @@ module Sources
text = text.gsub(%r{user/[0-9]+}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
diff --git a/test/unit/sources/pixiv_test.rb b/test/unit/sources/pixiv_test.rb
index 480fe19f2..8a58a9cc9 100644
--- a/test/unit/sources/pixiv_test.rb
+++ b/test/unit/sources/pixiv_test.rb
@@ -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])を一部加筆して再版しました。通販在庫復活しているのでよろしければ▷
+ 今週末京都みやこめっせで開催される「古明地こんぷれっくす いつつめ」にも持っていきます〜。スペースは【古13】です。他にも色々持って行く予定なので、改めて告知します。
+
+ ◇pixivFANBOX開設してみました。のんびり投稿していく予定です(:˒[ ̄]メイキングとかやってみたい…▶︎
+ EOS
+
+ assert_equal(dtext_desc.chomp, @site.dtext_artist_commentary_desc)
+ end
end
context "translating the tags" do