namespace VideoBrowser.Helpers { using System; using System.Web; /// /// Defines the . /// internal static class UrlHelper { #region Methods /// /// The GetValidUrl. /// /// The url. /// The . public static string GetValidUrl(string url) { if (!IsValidUrl(url)) { var encodedUrl = HttpUtility.UrlEncode(url); url = $"https://www.youtube.com/results?search_query={encodedUrl}"; } return url; } /// /// The IsValidUrl. /// /// The url. /// The . public static bool IsValidUrl(string url) { if (!url.Contains(".")) { return false; } if (!url.Contains("http")) { url = $"http://{url}"; } var result = Uri.TryCreate(url, UriKind.Absolute, out Uri uriResult) && (uriResult.Scheme == Uri.UriSchemeHttp || uriResult.Scheme == Uri.UriSchemeHttps); return result; } #endregion Methods } }