diff --git a/src/api.nim b/src/api.nim index cf6f177..dd19238 100644 --- a/src/api.nim +++ b/src/api.nim @@ -89,7 +89,7 @@ proc resolve*(url: string; prefs: Prefs): Future[string] {.async.} = let client = newAsyncHttpClient(maxRedirects=0) try: let resp = await client.request(url, HttpHead) - result = resp.headers["location"].replaceUrl(prefs) + result = resp.headers["location"].replaceUrls(prefs) except: discard finally: diff --git a/src/formatters.nim b/src/formatters.nim index 164e0a7..7d5de91 100644 --- a/src/formatters.nim +++ b/src/formatters.nim @@ -47,8 +47,8 @@ proc shortLink*(text: string; length=28): string = if result.len > length: result = result[0 ..< length] & "…" -proc replaceUrl*(url: string; prefs: Prefs; absolute=""): string = - result = url +proc replaceUrls*(body: string; prefs: Prefs; absolute=""): string = + result = body if prefs.replaceYouTube.len > 0 and ytRegex in result: result = result.replace(ytRegex, prefs.replaceYouTube) diff --git a/src/nitter.nim b/src/nitter.nim index 20cf8df..c8c8f8b 100644 --- a/src/nitter.nim +++ b/src/nitter.nim @@ -69,7 +69,7 @@ routes: get "/i/redirect": let url = decodeUrl(@"url") if url.len == 0: resp Http404 - redirect(replaceUrl(url, cookiePrefs())) + redirect(replaceUrls(url, cookiePrefs())) error Http404: resp Http404, showError("Page not found", cfg) diff --git a/src/views/profile.nim b/src/views/profile.nim index 08404f1..8e516b9 100644 --- a/src/views/profile.nim +++ b/src/views/profile.nim @@ -29,7 +29,7 @@ proc renderProfileCard*(profile: Profile; prefs: Prefs): VNode = if profile.bio.len > 0: tdiv(class="profile-bio"): p(dir="auto"): - verbatim replaceUrl(profile.bio, prefs) + verbatim replaceUrls(profile.bio, prefs) if profile.location.len > 0: tdiv(class="profile-location"): @@ -45,7 +45,7 @@ proc renderProfileCard*(profile: Profile; prefs: Prefs): VNode = if profile.website.len > 0: tdiv(class="profile-website"): span: - let url = replaceUrl(profile.website, prefs) + let url = replaceUrls(profile.website, prefs) icon "link" a(href=url): text shortLink(url) diff --git a/src/views/rss.nimf b/src/views/rss.nimf index f76be33..8afdbe1 100644 --- a/src/views/rss.nimf +++ b/src/views/rss.nimf @@ -33,7 +33,7 @@ Twitter feed for: ${desc}. Generated by ${cfg.hostname} #proc renderRssTweet(tweet: Tweet; prefs: Prefs; cfg: Config): string = #let tweet = tweet.retweet.get(tweet) #let urlPrefix = getUrlPrefix(cfg) -#let text = replaceUrl(tweet.text, prefs, absolute=urlPrefix) +#let text = replaceUrls(tweet.text, prefs, absolute=urlPrefix) #if tweet.quote.isSome and get(tweet.quote).available: # let quoteLink = getLink(get(tweet.quote))
${text}
${cfg.hostname}${quoteLink}