mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2025-02-06 12:49:06 +00:00
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;
|
|||
|
}
|
|||
|
}
|