From 3445b183cd1587aab69ade82b9dc5013d0e416a4 Mon Sep 17 00:00:00 2001 From: Cynthia Foxwell Date: Fri, 18 Apr 2025 21:37:39 -0600 Subject: [PATCH] fix same origin urls in mastoapi --- src/views/mastoapi.nim | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/views/mastoapi.nim b/src/views/mastoapi.nim index 9b81896..a5ee11a 100644 --- a/src/views/mastoapi.nim +++ b/src/views/mastoapi.nim @@ -3,7 +3,7 @@ import strutils, strformat, options, json, sequtils, times, math import ".."/[types, formatters, utils] proc formatTweetForMastoAPI*(tweet: Tweet, cfg: Config, prefs: Prefs): string = - var content = replaceUrls(tweet.text, prefs, absolute=getUrlPrefix(cfg)) + var content = replaceUrls(tweet.text, prefs, absolute=getUrlPrefix(cfg)).replace("href=\"//", "href=\"http://") if tweet.poll.isSome(): let poll = get(tweet.poll) @@ -24,7 +24,7 @@ proc formatTweetForMastoAPI*(tweet: Tweet, cfg: Config, prefs: Prefs): string = if tweet.quote.isSome(): let quote = get(tweet.quote) - quoteContent = replaceUrls(quote.text, prefs).replace("href=\"/", &"href=\"{getUrlPrefix(cfg)}/") + quoteContent = replaceUrls(quote.text, prefs, absolute=getUrlPrefix(cfg)).replace("href=\"//", "href=\"http://") quoteUrl = &"{getUrlPrefix(cfg)}/i/status/{quote.id}" content &= &"\n\n
{quote.user.fullName} (@{quote.user.username})\n{quoteContent}" @@ -42,7 +42,7 @@ proc formatTweetForMastoAPI*(tweet: Tweet, cfg: Config, prefs: Prefs): string = if tweet.birdwatch.isSome(): let note = get(tweet.birdwatch) - noteContent = replaceUrls(note.text, prefs) + noteContent = replaceUrls(note.text, prefs, absolute=getUrlPrefix(cfg)).replace("href=\"//", "href=\"http://") content &= &"\n\n
ⓘ {note.title}\n{noteContent}
" result = content.replace("\n", "
")