Skip to content

Commit

Permalink
upgrade mf2py to 2.0.1, add test for resolving relative URLs in content
Browse files Browse the repository at this point in the history
fixes #390, re microformats/mf2py#181 . thank you again @angelogladding!
  • Loading branch information
snarfed committed Dec 12, 2023
1 parent d1db72b commit 6c1ea6a
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ Jinja2==3.1.2
jsonschema==4.20.0
lxml==4.9.3
MarkupSafe==2.1.3
mf2py==1.1.3
mf2py==2.0.1
mf2util==0.5.2
multiformats==0.2.1
multiformats-config==0.2.0.post4
Expand Down
31 changes: 31 additions & 0 deletions tests/test_web.py
Original file line number Diff line number Diff line change
Expand Up @@ -2520,6 +2520,37 @@ def test_fetch_no_mf2(self, mock_get, __):
self.assertFalse(Web.fetch(obj))
self.assertIsNone(obj.as1)

def test_fetch_resolves_relative_urls(self, mock_get, __):
mock_get.return_value = requests_response("""\
<html>
<body class="h-entry">
<a class="u-url" href="repost"></a>
<a class="u-repost-of" href="/orig/post">reposted!</a>
<a class="u-author" href="/me"></a>
<p class="e-content">
Hello <img src="hi.jpg" class="u-photo"> <a href="/there">there</a>.
</p>
</body>
</html>
""", url='https://user.com/my/post')

obj = Object(id='https://user.com/post')
Web.fetch(obj)
self.assert_equals({
'type': ['h-entry'],
'properties': {
'url': ['https://user.com/my/repost'],
'repost-of': ['https://user.com/orig/post'],
'author': ['https://user.com/me'],
'photo': ['https://user.com/my/hi.jpg'],
'content': [{
'html': 'Hello <img class="u-photo" src="https://user.com/my/hi.jpg"/> <a href="https://user.com/there">there</a>.',
'value': 'Hello https://user.com/my/hi.jpg there.',
}],
},
'url': 'https://user.com/my/post',
}, obj.mf2)

def test_send_note_does_nothing(self, mock_get, mock_post):
Follower.get_or_create(
to=self.make_user('https://mas.to/bob', cls=ActivityPub),
Expand Down

0 comments on commit 6c1ea6a

Please sign in to comment.