private static bool IsUrlValid(string url)
{
// URLs can be relative.
if (url.StartsWith("/") || url.StartsWith("#"))
return true;
// Check the scheme is allowed.
bool schemeIsAllowed = false;
foreach (var scheme in HyperlinkInline.KnownSchemes)
{
if (url.StartsWith(scheme))
{
schemeIsAllowed = true;
break;
}
}
return schemeIsAllowed;
}