mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2025-02-05 23:09:07 +00:00
Thorsten Sommer
c84184e5d1
This is necessary due to issue https://github.com/MyNihongo/MudBlazor.Markdown/issues/247 I created a PR as well: https://github.com/MyNihongo/MudBlazor.Markdown/pull/246
29 lines
530 B
C#
29 lines
530 B
C#
namespace MudBlazor;
|
|
|
|
internal static class StringEx
|
|
{
|
|
public static bool IsExternalUri(this string? @this, string? baseUri)
|
|
{
|
|
if (string.IsNullOrEmpty(@this) || string.IsNullOrEmpty(baseUri))
|
|
return false;
|
|
|
|
try
|
|
{
|
|
var uri = new Uri(@this, UriKind.RelativeOrAbsolute);
|
|
return uri.IsAbsoluteUri && !@this.StartsWith(baseUri);
|
|
}
|
|
catch
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
|
|
public static int ParseOrDefault(this string? @this)
|
|
{
|
|
if (!int.TryParse(@this, out var intValue))
|
|
intValue = 0;
|
|
|
|
return intValue;
|
|
}
|
|
}
|