mirror of
https://github.com/bitwarden/mobile
synced 2026-01-08 11:33:31 +00:00
add support for uri match rules detection
This commit is contained in:
@@ -467,5 +467,37 @@ namespace Bit.App.Utilities
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static string GetUrlHost(string url)
|
||||
{
|
||||
if(string.IsNullOrWhiteSpace(url))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
url = url.Trim();
|
||||
if(url == string.Empty)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
if(!url.Contains("://"))
|
||||
{
|
||||
url = $"http://{url}";
|
||||
}
|
||||
|
||||
if(!Uri.TryCreate(url, UriKind.Absolute, out Uri u))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var host = u.Host;
|
||||
if(!u.IsDefaultPort)
|
||||
{
|
||||
host = $"{host}:{u.Port}";
|
||||
}
|
||||
|
||||
return host;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user