Release/ArtigosPDF #22
@ -19,43 +19,92 @@
|
||||
{
|
||||
if (string.IsNullOrEmpty(url)) return "#";
|
||||
|
||||
// Se já tem protocolo, retorna direto
|
||||
if (url.StartsWith("http://") || url.StartsWith("https://"))
|
||||
return url;
|
||||
|
||||
// WhatsApp - garantir prefixo wa.me
|
||||
// WhatsApp - sempre normalizar para evitar URLs malformadas
|
||||
if (!string.IsNullOrEmpty(icon) && icon.Contains("whatsapp"))
|
||||
{
|
||||
// Remove qualquer prefixo parcial que possa existir
|
||||
var cleanUrl = url.Replace("wa.me/", "").Replace("whatsapp://", "");
|
||||
// Remove qualquer prefixo conhecido (incluindo https://)
|
||||
var cleanUrl = url
|
||||
.Replace("https://wa.me/", "")
|
||||
.Replace("http://wa.me/", "")
|
||||
.Replace("https://api.whatsapp.com/send?phone=", "")
|
||||
.Replace("https://api.whatsapp.com/", "")
|
||||
.Replace("wa.me/", "")
|
||||
.Replace("whatsapp://send?phone=", "")
|
||||
.Replace("whatsapp://", "");
|
||||
|
||||
// Remove barras extras
|
||||
cleanUrl = cleanUrl.TrimStart('/').Trim();
|
||||
|
||||
// Apenas números devem sobrar
|
||||
return $"https://wa.me/{cleanUrl}";
|
||||
}
|
||||
|
||||
// Se já tem protocolo correto para outras redes, retorna direto
|
||||
if (url.StartsWith("http://") || url.StartsWith("https://"))
|
||||
return url;
|
||||
|
||||
// Facebook
|
||||
if (!string.IsNullOrEmpty(icon) && icon.Contains("facebook"))
|
||||
{
|
||||
var cleanUrl = url.Replace("facebook.com/", "").Replace("fb.com/", "");
|
||||
var cleanUrl = url
|
||||
.Replace("https://facebook.com/", "")
|
||||
.Replace("https://www.facebook.com/", "")
|
||||
.Replace("https://fb.com/", "")
|
||||
.Replace("https://www.fb.com/", "")
|
||||
.Replace("http://facebook.com/", "")
|
||||
.Replace("http://www.facebook.com/", "")
|
||||
.Replace("facebook.com/", "")
|
||||
.Replace("fb.com/", "")
|
||||
.TrimStart('/').Trim();
|
||||
return $"https://facebook.com/{cleanUrl}";
|
||||
}
|
||||
|
||||
// Instagram
|
||||
if (!string.IsNullOrEmpty(icon) && icon.Contains("instagram"))
|
||||
{
|
||||
var cleanUrl = url.Replace("instagram.com/", "").Replace("instagr.am/", "");
|
||||
var cleanUrl = url
|
||||
.Replace("https://instagram.com/", "")
|
||||
.Replace("https://www.instagram.com/", "")
|
||||
.Replace("https://instagr.am/", "")
|
||||
.Replace("http://instagram.com/", "")
|
||||
.Replace("http://www.instagram.com/", "")
|
||||
.Replace("instagram.com/", "")
|
||||
.Replace("instagr.am/", "")
|
||||
.TrimStart('/').Trim();
|
||||
return $"https://instagram.com/{cleanUrl}";
|
||||
}
|
||||
|
||||
// Twitter/X
|
||||
if (!string.IsNullOrEmpty(icon) && (icon.Contains("twitter") || icon.Contains("x-twitter")))
|
||||
{
|
||||
var cleanUrl = url.Replace("x.com/", "").Replace("twitter.com/", "");
|
||||
var cleanUrl = url
|
||||
.Replace("https://x.com/", "")
|
||||
.Replace("https://twitter.com/", "")
|
||||
.Replace("https://www.twitter.com/", "")
|
||||
.Replace("https://www.x.com/", "")
|
||||
.Replace("http://x.com/", "")
|
||||
.Replace("http://twitter.com/", "")
|
||||
.Replace("x.com/", "")
|
||||
.Replace("twitter.com/", "")
|
||||
.TrimStart('/').Trim();
|
||||
return $"https://x.com/{cleanUrl}";
|
||||
}
|
||||
|
||||
// TikTok
|
||||
if (!string.IsNullOrEmpty(icon) && icon.Contains("tiktok"))
|
||||
{
|
||||
var cleanUrl = url.Replace("tiktok.com/", "").Replace("tiktok.com/@", "");
|
||||
var cleanUrl = url
|
||||
.Replace("https://tiktok.com/@", "")
|
||||
.Replace("https://www.tiktok.com/@", "")
|
||||
.Replace("https://tiktok.com/", "")
|
||||
.Replace("https://www.tiktok.com/", "")
|
||||
.Replace("https://vm.tiktok.com/", "")
|
||||
.Replace("http://tiktok.com/@", "")
|
||||
.Replace("http://tiktok.com/", "")
|
||||
.Replace("tiktok.com/@", "")
|
||||
.Replace("tiktok.com/", "")
|
||||
.TrimStart('/').Trim();
|
||||
|
||||
// Se não tem @, adiciona
|
||||
if (!cleanUrl.StartsWith("@"))
|
||||
cleanUrl = "@" + cleanUrl;
|
||||
@ -65,14 +114,29 @@
|
||||
// Pinterest
|
||||
if (!string.IsNullOrEmpty(icon) && icon.Contains("pinterest"))
|
||||
{
|
||||
var cleanUrl = url.Replace("pinterest.com/", "").Replace("pin.it/", "");
|
||||
var cleanUrl = url
|
||||
.Replace("https://pinterest.com/", "")
|
||||
.Replace("https://www.pinterest.com/", "")
|
||||
.Replace("https://pin.it/", "")
|
||||
.Replace("http://pinterest.com/", "")
|
||||
.Replace("http://www.pinterest.com/", "")
|
||||
.Replace("pinterest.com/", "")
|
||||
.Replace("pin.it/", "")
|
||||
.TrimStart('/').Trim();
|
||||
return $"https://pinterest.com/{cleanUrl}";
|
||||
}
|
||||
|
||||
// Discord
|
||||
if (!string.IsNullOrEmpty(icon) && icon.Contains("discord"))
|
||||
{
|
||||
var cleanUrl = url.Replace("discord.gg/", "").Replace("discord.com/invite/", "");
|
||||
var cleanUrl = url
|
||||
.Replace("https://discord.gg/", "")
|
||||
.Replace("https://discord.com/invite/", "")
|
||||
.Replace("http://discord.gg/", "")
|
||||
.Replace("http://discord.com/invite/", "")
|
||||
.Replace("discord.gg/", "")
|
||||
.Replace("discord.com/invite/", "")
|
||||
.TrimStart('/').Trim();
|
||||
return $"https://discord.gg/{cleanUrl}";
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user