diff --git a/src/Core/Utilities/CoreHelpers.cs b/src/Core/Utilities/CoreHelpers.cs
index 95ba708c2..049f31229 100644
--- a/src/Core/Utilities/CoreHelpers.cs
+++ b/src/Core/Utilities/CoreHelpers.cs
@@ -38,12 +38,38 @@ namespace Bit.Core.Utilities
#endif
}
+ ///
+ /// Returns the host (and not port) of the given uri.
+ /// Does not support plain hostnames/only top level domain.
+ ///
+ /// Input => Output examples:
+ /// https://bitwarden.com => bitwarden.com
+ /// https://login.bitwarden.com:1337 => login.bitwarden.com
+ /// https://sub.login.bitwarden.com:1337 => sub.login.bitwarden.com
+ /// https://localhost:8080 => localhost
+ /// localhost => null
+ /// bitwarden => null
+ /// 127.0.0.1 => 127.0.0.1
+ ///
public static string GetHostname(string uriString)
{
var uri = GetUri(uriString);
return string.IsNullOrEmpty(uri?.Host) ? null : uri.Host;
}
+ ///
+ /// Returns the host and port of the given uri.
+ /// Does not support plain hostnames/only top level domain.
+ ///
+ /// Input => Output examples:
+ /// https://bitwarden.com => bitwarden.com
+ /// https://login.bitwarden.com:1337 => login.bitwarden.com:1337
+ /// https://sub.login.bitwarden.com:1337 => sub.login.bitwarden.com:1337
+ /// https://localhost:8080 => localhost:8080
+ /// localhost => null
+ /// bitwarden => null
+ /// 127.0.0.1 => 127.0.0.1
+ ///
public static string GetHost(string uriString)
{
var uri = GetUri(uriString);
@@ -61,6 +87,19 @@ namespace Bit.Core.Utilities
return null;
}
+ ///
+ /// Returns the second and top level domain of the given uri.
+ /// Does not support plain hostnames/only top level domain.
+ ///
+ /// Input => Output examples:
+ /// https://bitwarden.com => bitwarden.com
+ /// https://login.bitwarden.com:1337 => bitwarden.com
+ /// https://sub.login.bitwarden.com:1337 => bitwarden.com
+ /// https://localhost:8080 => localhost
+ /// localhost => null
+ /// bitwarden => null
+ /// 127.0.0.1 => 127.0.0.1
+ ///
public static string GetDomain(string uriString)
{
var uri = GetUri(uriString);