1
0
mirror of https://github.com/Radarr/Radarr.git synced 2026-04-18 21:35:51 -04:00
Files
Radarr/src/NzbDrone.Common/Extensions/UrlExtensions.cs
2017-07-26 22:57:38 +02:00

35 lines
693 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;
}
Uri uri;
if (!Uri.TryCreate(path, UriKind.Absolute, out uri))
{
return false;
}
if (!uri.IsWellFormedOriginalString())
{
return false;
}
return true;
}
}
}