Additional uri parsing intelligence (#861)

This commit is contained in:
Matt Portune 2020-04-29 13:09:46 -04:00 committed by GitHub
parent 69e0906491
commit 9d27f111bf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 4 deletions

View file

@ -164,11 +164,15 @@ namespace Bit.Droid.Accessibility
{ {
return uri; return uri;
} }
var hasHttpProtocol = uri.StartsWith("http://") || uri.StartsWith("https://");
if (!hasHttpProtocol && uri.Contains("."))
{
if (Uri.TryCreate("http://" + uri, UriKind.Absolute, out var uri3)) if (Uri.TryCreate("http://" + uri, UriKind.Absolute, out var uri3))
{ {
return string.Concat("http://", uri); return string.Concat("http://", uri);
} }
} }
}
return uri; return uri;
} }

View file

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