1
0
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:
Kyle Spearrin
2018-03-05 23:37:02 -05:00
parent 4c8204f29a
commit 005b2a4fb6
2 changed files with 148 additions and 61 deletions

View File

@@ -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;
}
}
}