[backend/federation] Prettier displayUri for profile fields that are links
This commit is contained in:
parent
ec6a3f5e73
commit
f6bfaa72ad
1 changed files with 5 additions and 3 deletions
|
@ -100,8 +100,10 @@ public class UserRenderer(IOptions<Config.InstanceSection> config, DatabaseConte
|
|||
private static string RenderFieldValue(string value)
|
||||
{
|
||||
if (!value.StartsWith("http://") && !value.StartsWith("https://")) return value;
|
||||
return !Uri.TryCreate(value, UriKind.Absolute, out var result)
|
||||
? value
|
||||
: $"<a href=\"{result.ToString()}\" rel=\"me nofollow noopener\" target=\"_blank\">{value}</a>";
|
||||
if (!Uri.TryCreate(value, UriKind.Absolute, out var uri))
|
||||
return value;
|
||||
|
||||
var displayUri = uri.Host + uri.PathAndQuery + uri.Fragment;
|
||||
return $"<a href=\"{uri.ToString()}\" rel=\"me nofollow noopener\" target=\"_blank\">{displayUri}</a>";
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue