fix(formatters): replacement for on.soundcloud.com now points to soundcloak/on/

This commit is contained in:
2025-11-18 17:48:44 -03:00
parent 2e2a96d7d8
commit 8d87371763

View File

@@ -17,8 +17,7 @@ let
imgurLinkRegex = re"""<a href="https://(i\.)?imgur.com([^"]+)">(i\.)?imgur\.com(\S+)</a>""" imgurLinkRegex = re"""<a href="https://(i\.)?imgur.com([^"]+)">(i\.)?imgur\.com(\S+)</a>"""
fandomRegex = re"(?<=(?<!\S)https:\/\/|(?<=\s))([a-z0-9-]+)\.fandom\.com" fandomRegex = re"(?<=(?<!\S)https:\/\/|(?<=\s))([a-z0-9-]+)\.fandom\.com"
fandomLinkRegex = re"""<a href="https://([a-z0-9-]+)\.fandom\.com([^"]+)">([a-z0-9-]+)\.fandom\.com(\S+)</a>""" fandomLinkRegex = re"""<a href="https://([a-z0-9-]+)\.fandom\.com([^"]+)">([a-z0-9-]+)\.fandom\.com(\S+)</a>"""
soundcloudRegex = re"(?<=(?<!\S)https:\/\/|(?<=\s))(www\.)?soundcloud\.com" soundcloudRegex = re"(?<=(?<!\S)https:\/\/|(?<=\s))(on\.|www\.)?soundcloud\.com"
soundcloudLinkRegex = re"""<a href="https://(www\.)?soundcloud\.com([^"]+)">(www\.)?soundcloud\.com(\S+)</a>"""
ytRegex = re(r"([A-z.]+\.)?youtu(be\.com|\.be)", {reStudy, reIgnoreCase}) ytRegex = re(r"([A-z.]+\.)?youtu(be\.com|\.be)", {reStudy, reIgnoreCase})
@@ -91,7 +90,9 @@ proc replaceUrls*(body: string; prefs: Prefs; absolute=""): string =
if prefs.replaceSoundCloud.len > 0 and "soundcloud.com" in result: if prefs.replaceSoundCloud.len > 0 and "soundcloud.com" in result:
result = result.replace(soundcloudRegex, prefs.replaceSoundCloud) result = result.replace(soundcloudRegex, prefs.replaceSoundCloud)
result = result.replacef(soundcloudLinkRegex, a( result = result.replacef(re"""<a href="https://on\.soundcloud\.com([^"]+)">on\.soundcloud\.com(\S+)</a>""", a(
prefs.replaceSoundCloud & "/on$2", href = https & prefs.replaceSoundCloud & "/on$1"))
result = result.replacef(re"""<a href="https://(www\.)?soundcloud\.com([^"]+)">(www\.)?soundcloud\.com(\S+)</a>""", a(
prefs.replaceSoundCloud & "$4", href = https & prefs.replaceSoundCloud & "$2")) prefs.replaceSoundCloud & "$4", href = https & prefs.replaceSoundCloud & "$2"))
if prefs.replaceReddit.len > 0 and ("reddit.com" in result or "redd.it" in result): if prefs.replaceReddit.len > 0 and ("reddit.com" in result or "redd.it" in result):