Skip to content

Commit

Permalink
parse uri with Uri.TryCreate
Browse files Browse the repository at this point in the history
  • Loading branch information
kspearrin committed Feb 26, 2017
1 parent 8e5a01d commit 375f23a
Showing 1 changed file with 9 additions and 16 deletions.
25 changes: 9 additions & 16 deletions src/App/Models/Page/VaultViewLoginPageModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -126,26 +126,19 @@ public string UriHost
return _uriHost;
}

try
Uri uri;
if(!System.Uri.TryCreate(Uri, UriKind.Absolute, out uri))
{
var host = new Uri(Uri).Host;

DomainName domain;
if(DomainName.TryParse(host, out domain))
{
_uriHost = domain.BaseDomain;
}
else
{
_uriHost = host;
}

return _uriHost;
return Uri;
}
catch

DomainName domain;
if(DomainName.TryParse(uri.Host, out domain))
{
return Uri;
return domain.BaseDomain;
}

return uri.Host;
}
}

Expand Down

0 comments on commit 375f23a

Please sign in to comment.