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