Files
Readarr/src/NzbDrone.Common/Extensions/UrlExtensions.cs
T
Stepan Goremykin 28f64d9a46 Migrate to FluentValidation 9
(cherry picked from commit 40e54685b9e83ed24a3979bfe965c453339ad02e)
2023-05-07 17:57:58 +03:00

23 lines
519 B
C#

using System;
namespace NzbDrone.Common.Extensions
{
public static class UrlExtensions
{
public static bool IsValidUrl(this string path)
{
if (string.IsNullOrWhiteSpace(path))
{
return false;
}
if (path.StartsWith(" ") || path.EndsWith(" "))
{
return false;
}
return Uri.TryCreate(path, UriKind.Absolute, out var uri) && uri.IsWellFormedOriginalString();
}
}
}