Projektdateien hinzufügen.

This commit is contained in:
Kevin Krüger
2023-07-24 12:00:34 +02:00
parent 656751e10b
commit 0d00a90942
210 changed files with 45049 additions and 0 deletions

View File

@@ -0,0 +1,53 @@
namespace VideoBrowser.Helpers
{
using System;
using System.Web;
/// <summary>
/// Defines the <see cref="UrlHelper" />.
/// </summary>
internal static class UrlHelper
{
#region Methods
/// <summary>
/// The GetValidUrl.
/// </summary>
/// <param name="url">The url<see cref="string"/>.</param>
/// <returns>The <see cref="string"/>.</returns>
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;
}
/// <summary>
/// The IsValidUrl.
/// </summary>
/// <param name="url">The url<see cref="string"/>.</param>
/// <returns>The <see cref="bool"/>.</returns>
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
}
}