Merge branch 'bugfix/rel-me_list' into 'develop'
Web.RelMe: Fix having other values in rel attr See merge request pleroma/pleroma!901
This commit is contained in:
commit
07f8c79a69
@ -28,7 +28,8 @@ defmodule Pleroma.Web.RelMe do
|
|||||||
{:ok, %Tesla.Env{body: html}} = Pleroma.HTTP.get(url, [], adapter: @hackney_options)
|
{:ok, %Tesla.Env{body: html}} = Pleroma.HTTP.get(url, [], adapter: @hackney_options)
|
||||||
|
|
||||||
data =
|
data =
|
||||||
Floki.attribute(html, "link[rel=me]", "href") ++ Floki.attribute(html, "a[rel=me]", "href")
|
Floki.attribute(html, "link[rel~=me]", "href") ++
|
||||||
|
Floki.attribute(html, "a[rel~=me]", "href")
|
||||||
|
|
||||||
{:ok, data}
|
{:ok, data}
|
||||||
rescue
|
rescue
|
||||||
|
14
test/fixtures/rel_me_anchor_nofollow.html
vendored
Normal file
14
test/fixtures/rel_me_anchor_nofollow.html
vendored
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8"/>
|
||||||
|
<title>Blog</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<article>
|
||||||
|
<h1>Lorem ipsum</h1>
|
||||||
|
<p>Lorem ipsum dolor sit ameph, …</p>
|
||||||
|
<a rel="me nofollow" href="https://social.example.org/users/lain">lain’s account</a>
|
||||||
|
</article>
|
||||||
|
</body>
|
||||||
|
</html>
|
1
test/fixtures/rel_me_null.html
vendored
1
test/fixtures/rel_me_null.html
vendored
@ -8,6 +8,7 @@
|
|||||||
<article>
|
<article>
|
||||||
<h1>Lorem ipsum</h1>
|
<h1>Lorem ipsum</h1>
|
||||||
<p>Lorem ipsum dolor sit ameph, …</p>
|
<p>Lorem ipsum dolor sit ameph, …</p>
|
||||||
|
<a rel="nofollow" href="https://social.example.org/users/lain">lain’s account</a>
|
||||||
</article>
|
</article>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
@ -11,6 +11,12 @@ defmodule Pleroma.Web.RelMeTest do
|
|||||||
|
|
||||||
%{
|
%{
|
||||||
method: :get,
|
method: :get,
|
||||||
|
url: "http://example.com/rel_me/anchor_nofollow"
|
||||||
|
} ->
|
||||||
|
%Tesla.Env{status: 200, body: File.read!("test/fixtures/rel_me_anchor_nofollow.html")}
|
||||||
|
|
||||||
|
%{
|
||||||
|
method: :get,
|
||||||
url: "http://example.com/rel_me/link"
|
url: "http://example.com/rel_me/link"
|
||||||
} ->
|
} ->
|
||||||
%Tesla.Env{status: 200, body: File.read!("test/fixtures/rel_me_link.html")}
|
%Tesla.Env{status: 200, body: File.read!("test/fixtures/rel_me_link.html")}
|
||||||
@ -33,6 +39,7 @@ defmodule Pleroma.Web.RelMeTest do
|
|||||||
|
|
||||||
assert Pleroma.Web.RelMe.parse("http://example.com/rel_me/link") == {:ok, hrefs}
|
assert Pleroma.Web.RelMe.parse("http://example.com/rel_me/link") == {:ok, hrefs}
|
||||||
assert Pleroma.Web.RelMe.parse("http://example.com/rel_me/anchor") == {:ok, hrefs}
|
assert Pleroma.Web.RelMe.parse("http://example.com/rel_me/anchor") == {:ok, hrefs}
|
||||||
|
assert Pleroma.Web.RelMe.parse("http://example.com/rel_me/anchor_nofollow") == {:ok, hrefs}
|
||||||
end
|
end
|
||||||
|
|
||||||
test "maybe_put_rel_me/2" do
|
test "maybe_put_rel_me/2" do
|
||||||
@ -49,6 +56,11 @@ defmodule Pleroma.Web.RelMeTest do
|
|||||||
assert Pleroma.Web.RelMe.maybe_put_rel_me("http://example.com/rel_me/anchor", profile_urls) ==
|
assert Pleroma.Web.RelMe.maybe_put_rel_me("http://example.com/rel_me/anchor", profile_urls) ==
|
||||||
attr
|
attr
|
||||||
|
|
||||||
|
assert Pleroma.Web.RelMe.maybe_put_rel_me(
|
||||||
|
"http://example.com/rel_me/anchor_nofollow",
|
||||||
|
profile_urls
|
||||||
|
) == attr
|
||||||
|
|
||||||
assert Pleroma.Web.RelMe.maybe_put_rel_me("http://example.com/rel_me/link", profile_urls) ==
|
assert Pleroma.Web.RelMe.maybe_put_rel_me("http://example.com/rel_me/link", profile_urls) ==
|
||||||
attr
|
attr
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user