From 0c18ba8e3a526d4829846bbdcaa0e7a9e1bca5a2 Mon Sep 17 00:00:00 2001 From: user Date: Thu, 19 Feb 2026 18:33:13 +0100 Subject: [PATCH] feat: append source domain fragment to alert short URLs Short URLs now include the original source domain as a URL fragment, e.g. https://paste.mymx.me/s/foo#github.com, so the destination is visible before clicking. Co-Authored-By: Claude Opus 4.6 --- plugins/alert.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/plugins/alert.py b/plugins/alert.py index 2ed8c46..2cd379f 100644 --- a/plugins/alert.py +++ b/plugins/alert.py @@ -12,6 +12,7 @@ import urllib.request from datetime import datetime, timezone from html.parser import HTMLParser from pathlib import Path +from urllib.parse import urlparse from derp.http import urlopen as _urlopen from derp.plugin import command, event @@ -1909,7 +1910,8 @@ async def _poll_once(bot, key: str, announce: bool = True) -> None: None, fp.shorten_url, bot, url, ) if short_url != url: - display_url = short_url + domain = urlparse(url).hostname or "" + display_url = f"{short_url}#{domain}" if domain else short_url else: short_url = "" except Exception: @@ -2104,14 +2106,17 @@ async def cmd_alert(bot, message): title = _truncate(title) if title else "(no title)" if extra: title = f"{title} | {extra}" - display_url = short_url or url + domain = urlparse(url).hostname or "" if url else "" + display_url = (f"{short_url}#{domain}" if short_url and domain + else short_url or url) if fp and url and not short_url: try: new_short = await loop.run_in_executor( None, fp.shorten_url, bot, url, ) if new_short != url: - display_url = new_short + display_url = (f"{new_short}#{domain}" if domain + else new_short) db.execute( "UPDATE results SET short_url = ? WHERE id = ?", (new_short, row_id),