From 1bc6d0983506bc02d5936102903bbfb8d8200c29 Mon Sep 17 00:00:00 2001 From: MathiasDPX Date: Tue, 15 Apr 2025 14:32:09 +0200 Subject: [PATCH] add url to formatContent --- routes/scrapbook.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/routes/scrapbook.py b/routes/scrapbook.py index 739b01f..50e39ff 100644 --- a/routes/scrapbook.py +++ b/routes/scrapbook.py @@ -34,10 +34,18 @@ def convert_slack_references(text): def channel_replacement(match): channel_id = match.group(1) channel_name = channels_maps.get(channel_id, channel_id) - return f'#{channel_name}' + return f'#{channel_name}' result = re.sub(channel_pattern, channel_replacement, text) - + + url_pattern = r'<(https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*))>' + + def url_replacement(match): + url = match.group(1) + return f'{url}' + + result = re.sub(url_pattern, url_replacement, text) + return result @sp_routes.route("/scrapbook")