From a285fdf29e59c3b957247ea9241943c7202e9a28 Mon Sep 17 00:00:00 2001 From: Dennis Fink Date: Fri, 13 Nov 2026 21:20:40 +0100 Subject: refactor(core): consolidate repeated helper logic Centralize SQL row counts, hostname parsing, and content-type normalization so tasks, forms, and scanners share consistent implementations. Simplify periodic task registration and admin lookups with table-driven setup and Flask-SQLAlchemy's built-in 404 helper. --- webmentions_ssg/tasks/discovery.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'webmentions_ssg/tasks/discovery.py') diff --git a/webmentions_ssg/tasks/discovery.py b/webmentions_ssg/tasks/discovery.py index 107d30a..becac58 100644 --- a/webmentions_ssg/tasks/discovery.py +++ b/webmentions_ssg/tasks/discovery.py @@ -14,6 +14,7 @@ from flask import current_app from ..net import ( ResponseTooLargeError, + content_type_of, is_http_url, is_temporary_status, read_limited_body, @@ -173,9 +174,7 @@ def discover_webmention_endpoint(client: httpx.Client, target: str) -> str | Non if not response.is_success: raise PermanentSenderError(f"Target returned HTTP {response.status_code}") - media_type = ( - response.headers.get("Content-Type", "").partition(";")[0].strip().lower() - ) + media_type = content_type_of(response.headers) if media_type not in {"text/html", "application/xhtml+xml"}: return None -- cgit v1.3.1