base domain proerpty for domain name

This commit is contained in:
Kyle Spearrin 2016-06-26 00:32:22 -04:00
parent 954e2294c0
commit 76cf566c9e
4 changed files with 23 additions and 6 deletions

View file

@ -20,6 +20,7 @@ namespace Bit.App.Models
public string SLD => _domain; public string SLD => _domain;
public string TLD => _tld; public string TLD => _tld;
public TLDRule Rule => _tldRule; public TLDRule Rule => _tldRule;
public string BaseDomain => $"{_domain}.{_tld}";
public DomainName(string TLD, string SLD, string SubDomain, TLDRule TLDRule) public DomainName(string TLD, string SLD, string SubDomain, TLDRule TLDRule)
{ {

View file

@ -81,14 +81,16 @@ namespace Bit.App.Models.Page
try try
{ {
var host = new Uri(Uri).Host;
DomainName domain; DomainName domain;
if(DomainName.TryParse(Uri, out domain)) if(DomainName.TryParse(host, out domain))
{ {
_uriHost = domain.Domain; _uriHost = domain.BaseDomain;
} }
else else
{ {
_uriHost = new Uri(Uri).Host; _uriHost = host;
} }
return _uriHost; return _uriHost;

View file

@ -40,7 +40,7 @@ namespace Bit.iOS.Extension
var siteService = Resolver.Resolve<ISiteService>(); var siteService = Resolver.Resolve<ISiteService>();
var sites = await siteService.GetAllAsync(); var sites = await siteService.GetAllAsync();
var siteModels = sites.Select(s => new SiteViewModel(s)); 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); tableView.Source = new TableSource(filteredSiteModels, this);

View file

@ -7,6 +7,7 @@ namespace Bit.iOS.Extension.Models
{ {
public class SiteViewModel public class SiteViewModel
{ {
private string _uri;
private DomainName _domain = null; private DomainName _domain = null;
private bool _domainParsed = false; private bool _domainParsed = false;
@ -23,7 +24,15 @@ namespace Bit.iOS.Extension.Models
public string Name { get; set; } public string Name { get; set; }
public string Username { get; set; } public string Username { get; set; }
public string Password { 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 public string HostName
{ {
get get
@ -48,6 +57,11 @@ namespace Bit.iOS.Extension.Models
{ {
get get
{ {
if(string.IsNullOrWhiteSpace(Uri))
{
return null;
}
if(_domainParsed) if(_domainParsed)
{ {
return _domain; return _domain;
@ -56,7 +70,7 @@ namespace Bit.iOS.Extension.Models
_domainParsed = true; _domainParsed = true;
DomainName domain; DomainName domain;
if(DomainName.TryParse(Uri, out domain)) if(DomainName.TryParse(HostName, out domain))
{ {
_domain = domain; _domain = domain;
} }