Skip to content

Commit f29879a

Browse files
committed
discover webmention endpoints in <a> tags as well as <link>
background: converspace/webmention#32
1 parent f2e7eff commit f29879a

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

webmentiontools/send.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,14 @@ def _discoverEndpoint(self):
4949
# look in the content
5050
html = r.text
5151
soup = BeautifulSoup(html)
52-
tag = soup.find('link', attrs={'rel': 'webmention'})
53-
if not tag:
54-
# backward compatibility with the webmention 0.1 spec
55-
tag = soup.find('link', attrs={'rel': 'http://webmention.org/'})
52+
tag = None
53+
for name in 'link', 'a':
54+
for rel in 'webmention', 'http://webmention.org/':
55+
tag = soup.find(name, attrs={'rel': rel})
56+
if tag:
57+
break
5658

57-
if tag and tag['href']:
59+
if tag and tag.get('href'):
5860
# add the base scheme and host to relative endpoints
5961
self.receiver_endpoint = urlparse.urljoin(self.target_url, tag['href'])
6062
else:

0 commit comments

Comments
 (0)