mirror of
https://github.com/ICDSystems/ICD.Common.Utils.git
synced 2026-02-11 02:35:05 +00:00
35 lines
813 B
C#
35 lines
813 B
C#
using System;
|
|
using System.Linq;
|
|
|
|
namespace ICD.Common.Utils.Extensions
|
|
{
|
|
public static class UriExtensions
|
|
{
|
|
/// <summary>
|
|
/// Gets the username from the given URI.
|
|
/// </summary>
|
|
/// <param name="extends"></param>
|
|
/// <returns></returns>
|
|
public static string GetUserName(this Uri extends)
|
|
{
|
|
if (extends == null)
|
|
throw new ArgumentNullException("extends");
|
|
|
|
return extends.UserInfo.Split(':').FirstOrDefault(string.Empty);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets the password from the given URI.
|
|
/// </summary>
|
|
/// <param name="extends"></param>
|
|
/// <returns></returns>
|
|
public static string GetPassword(this Uri extends)
|
|
{
|
|
if (extends == null)
|
|
throw new ArgumentNullException("extends");
|
|
|
|
return extends.UserInfo.Split(':').Skip(1).FirstOrDefault(string.Empty);
|
|
}
|
|
}
|
|
}
|