GitHub Actions Runner

This commit is contained in:
Tingluo Huang
2019-10-10 00:52:42 -04:00
commit c8afc84840
1255 changed files with 198670 additions and 0 deletions

View File

@@ -0,0 +1,37 @@
using System;
namespace GitHub.Runner.Sdk
{
public static class UrlUtil
{
public static Uri GetCredentialEmbeddedUrl(Uri baseUrl, string username, string password)
{
ArgUtil.NotNull(baseUrl, nameof(baseUrl));
// return baseurl when there is no username and password
if (string.IsNullOrEmpty(username) && string.IsNullOrEmpty(password))
{
return baseUrl;
}
UriBuilder credUri = new UriBuilder(baseUrl);
// ensure we have a username, uribuild will throw if username is empty but password is not.
if (string.IsNullOrEmpty(username))
{
username = "emptyusername";
}
// escape chars in username for uri
credUri.UserName = Uri.EscapeDataString(username);
// escape chars in password for uri
if (!string.IsNullOrEmpty(password))
{
credUri.Password = Uri.EscapeDataString(password);
}
return credUri.Uri;
}
}
}