Additional URI parsing fix (#865)

* Additional URI parsing fix

* name cleanup
This commit is contained in:
Matt Portune 2020-04-30 16:47:29 -04:00 committed by GitHub
parent 99dceda8ac
commit 36cdc7dd1c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 11 deletions

View file

@ -161,18 +161,18 @@ namespace Bit.Droid.Accessibility
uri = browser.GetUriFunction(addressNode.Text)?.Trim(); uri = browser.GetUriFunction(addressNode.Text)?.Trim();
if (uri != null && uri.Contains(".")) if (uri != null && uri.Contains("."))
{ {
if (Uri.TryCreate(uri, UriKind.Absolute, out var uri2))
{
return uri;
}
var hasHttpProtocol = uri.StartsWith("http://") || uri.StartsWith("https://"); var hasHttpProtocol = uri.StartsWith("http://") || uri.StartsWith("https://");
if (!hasHttpProtocol && uri.Contains(".")) if (!hasHttpProtocol && uri.Contains("."))
{ {
if (Uri.TryCreate("http://" + uri, UriKind.Absolute, out var uri3)) if (Uri.TryCreate("http://" + uri, UriKind.Absolute, out var uri2))
{ {
return string.Concat("http://", uri); return string.Concat("http://", uri);
} }
} }
if (Uri.TryCreate(uri, UriKind.Absolute, out var uri3))
{
return uri;
}
} }
return uri; return uri;
} }

View file

@ -85,18 +85,18 @@ namespace Bit.Core.Utilities
{ {
return null; return null;
} }
if (Uri.TryCreate(uriString, UriKind.Absolute, out var uri))
{
return uri;
}
var hasHttpProtocol = uriString.StartsWith("http://") || uriString.StartsWith("https://"); var hasHttpProtocol = uriString.StartsWith("http://") || uriString.StartsWith("https://");
if (!hasHttpProtocol && uriString.Contains(".")) if (!hasHttpProtocol && uriString.Contains("."))
{ {
if (Uri.TryCreate("http://" + uriString, UriKind.Absolute, out var uri2)) if (Uri.TryCreate("http://" + uriString, UriKind.Absolute, out var uri))
{ {
return uri2; return uri;
} }
} }
if (Uri.TryCreate(uriString, UriKind.Absolute, out var uri2))
{
return uri2;
}
return null; return null;
} }