wasSharp

Subversion Repositories:
Compare Path: Rev
With Path: Rev
?path1? @ 31  →  ?path2? @ 32
/Web/Utilities/WebExtensions.cs
@@ -78,6 +78,7 @@
///////////////////////////////////////////////////////////////////////////
// Copyright (C) Wizardry and Steamworks 2015 - License: GNU GPLv3 //
///////////////////////////////////////////////////////////////////////////
/// <summary>Retrieves the port from an HttpListener prefix</summary>
/// <param name="prefix">a HttpListener prefix</param>
/// <returns>the port of the HttpListener</returns>
public static long GetPortFromPrefix(this string prefix)
@@ -90,5 +91,32 @@
long port;
return split.Length <= 1 || !long.TryParse(split[1], out port) ? 80 : port;
}
 
///////////////////////////////////////////////////////////////////////////
// Copyright (C) Wizardry and Steamworks 2017 - License: GNU GPLv3 //
///////////////////////////////////////////////////////////////////////////
/// <summary>
/// Compare Two URIs
/// </summary>
/// <param name="l">the URI to compare</param>
/// <param name="r">the URI to compare to</param>
/// <param name="components">optionally the components to compare</param>
/// <returns>true if the URIs match</returns>
public static bool UriIsEqualTo(this string l, string r,
UriComponents components = UriComponents.Host | UriComponents.PathAndQuery)
{
try
{
Uri a = new Uri(l);
Uri b = new Uri(r);
 
return Uri.Compare(a, b, components,
UriFormat.SafeUnescaped, StringComparison.OrdinalIgnoreCase) == 0;
}
catch
{
return false;
}
}
}
}