From 76cf566c9ef9658e15a31d34a74cf09ba2106782 Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Sun, 26 Jun 2016 00:32:22 -0400 Subject: [PATCH] base domain proerpty for domain name --- src/App/Models/DomainName.cs | 1 + src/App/Models/Page/VaultViewSitePageModel.cs | 8 +++++--- src/iOS.Extension/ActionViewController.cs | 2 +- src/iOS.Extension/Models/SiteViewModel.cs | 18 ++++++++++++++++-- 4 files changed, 23 insertions(+), 6 deletions(-) diff --git a/src/App/Models/DomainName.cs b/src/App/Models/DomainName.cs index 72771da73..dd1fd7700 100644 --- a/src/App/Models/DomainName.cs +++ b/src/App/Models/DomainName.cs @@ -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) { diff --git a/src/App/Models/Page/VaultViewSitePageModel.cs b/src/App/Models/Page/VaultViewSitePageModel.cs index 2bb74725a..2bd7acb22 100644 --- a/src/App/Models/Page/VaultViewSitePageModel.cs +++ b/src/App/Models/Page/VaultViewSitePageModel.cs @@ -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; diff --git a/src/iOS.Extension/ActionViewController.cs b/src/iOS.Extension/ActionViewController.cs index e497ec864..79e746480 100644 --- a/src/iOS.Extension/ActionViewController.cs +++ b/src/iOS.Extension/ActionViewController.cs @@ -40,7 +40,7 @@ namespace Bit.iOS.Extension var siteService = Resolver.Resolve(); 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); diff --git a/src/iOS.Extension/Models/SiteViewModel.cs b/src/iOS.Extension/Models/SiteViewModel.cs index d9ad03a14..5f86539be 100644 --- a/src/iOS.Extension/Models/SiteViewModel.cs +++ b/src/iOS.Extension/Models/SiteViewModel.cs @@ -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; }