diff options
| author | Dennis Fink | 2026-11-12 23:10:55 +0100 |
|---|---|---|
| committer | Dennis Fink | 2026-11-12 23:10:55 +0100 |
| commit | b439de2005b70ec3867d589d1f4c63b83441e620 (patch) | |
| tree | 8946413d4ab5ab92c0f81012ea9dce79ebb046ae /webmentions_ssg | |
| parent | 8f4f9041c60991457ccb1b3f145676d90e28aa8c (diff) | |
| download | webmentions-ssg-b439de2005b70ec3867d589d1f4c63b83441e620.tar.gz webmentions-ssg-b439de2005b70ec3867d589d1f4c63b83441e620.zip | |
refactor(sender): simplify HTML endpoint discovery
Use a case-insensitive CSS selector to find Webmention links directly,
removing manual relation parsing while preserving endpoint validation
and document order.
Diffstat (limited to '')
| -rw-r--r-- | webmentions_ssg/tasks/discovery.py | 25 |
1 files changed, 4 insertions, 21 deletions
diff --git a/webmentions_ssg/tasks/discovery.py b/webmentions_ssg/tasks/discovery.py index ddf5817..29c3e81 100644 --- a/webmentions_ssg/tasks/discovery.py +++ b/webmentions_ssg/tasks/discovery.py @@ -113,28 +113,11 @@ def endpoint_from_html(response: httpx.Response, body: bytes) -> str | None: """ document = BeautifulSoup(body, "html5lib") - for element in document.find_all(["link", "a"], href=True): - relations = element.get("rel") - - if isinstance(relations, str): - relations = relations.split() - - if not relations: - continue - - if not any( - isinstance(relation, str) and relation.lower() == "webmention" - for relation in relations - ): - continue - - href = element.get("href") - - if not isinstance(href, str): - continue - + for element in document.select( + 'link[rel~="webmention" i][href], a[rel~="webmention" i][href]' + ): try: - return resolve_endpoint(response, href) + return resolve_endpoint(response, str(element["href"])) except PermanentSenderError: continue |
