mirror of
https://github.com/bitwarden/android.git
synced 2024-12-24 09:58:27 +03:00
base domain proerpty for domain name
This commit is contained in:
parent
954e2294c0
commit
76cf566c9e
4 changed files with 23 additions and 6 deletions
|
@ -20,6 +20,7 @@ namespace Bit.App.Models
|
|||
public string SLD => _domain;
|
||||
public string TLD => _tld;
|
||||
public TLDRule Rule => _tldRule;
|
||||
public string BaseDomain => $"{_domain}.{_tld}";
|
||||
|
||||
public DomainName(string TLD, string SLD, string SubDomain, TLDRule TLDRule)
|
||||
{
|
||||
|
|
|
@ -81,14 +81,16 @@ namespace Bit.App.Models.Page
|
|||
|
||||
try
|
||||
{
|
||||
var host = new Uri(Uri).Host;
|
||||
|
||||
DomainName domain;
|
||||
if(DomainName.TryParse(Uri, out domain))
|
||||
if(DomainName.TryParse(host, out domain))
|
||||
{
|
||||
_uriHost = domain.Domain;
|
||||
_uriHost = domain.BaseDomain;
|
||||
}
|
||||
else
|
||||
{
|
||||
_uriHost = new Uri(Uri).Host;
|
||||
_uriHost = host;
|
||||
}
|
||||
|
||||
return _uriHost;
|
||||
|
|
|
@ -40,7 +40,7 @@ namespace Bit.iOS.Extension
|
|||
var siteService = Resolver.Resolve<ISiteService>();
|
||||
var sites = await siteService.GetAllAsync();
|
||||
var siteModels = sites.Select(s => new SiteViewModel(s));
|
||||
filteredSiteModels = siteModels.Where(s => s.Domain.Domain == domain.Domain);
|
||||
filteredSiteModels = siteModels.Where(s => s.Domain.BaseDomain == domain.BaseDomain);
|
||||
}
|
||||
|
||||
tableView.Source = new TableSource(filteredSiteModels, this);
|
||||
|
|
|
@ -7,6 +7,7 @@ namespace Bit.iOS.Extension.Models
|
|||
{
|
||||
public class SiteViewModel
|
||||
{
|
||||
private string _uri;
|
||||
private DomainName _domain = null;
|
||||
private bool _domainParsed = false;
|
||||
|
||||
|
@ -23,7 +24,15 @@ namespace Bit.iOS.Extension.Models
|
|||
public string Name { get; set; }
|
||||
public string Username { get; set; }
|
||||
public string Password { get; set; }
|
||||
public string Uri { get; set; }
|
||||
public string Uri
|
||||
{
|
||||
get { return _uri; }
|
||||
set
|
||||
{
|
||||
_domainParsed = false;
|
||||
_uri = value;
|
||||
}
|
||||
}
|
||||
public string HostName
|
||||
{
|
||||
get
|
||||
|
@ -48,6 +57,11 @@ namespace Bit.iOS.Extension.Models
|
|||
{
|
||||
get
|
||||
{
|
||||
if(string.IsNullOrWhiteSpace(Uri))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
if(_domainParsed)
|
||||
{
|
||||
return _domain;
|
||||
|
@ -56,7 +70,7 @@ namespace Bit.iOS.Extension.Models
|
|||
_domainParsed = true;
|
||||
|
||||
DomainName domain;
|
||||
if(DomainName.TryParse(Uri, out domain))
|
||||
if(DomainName.TryParse(HostName, out domain))
|
||||
{
|
||||
_domain = domain;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue