From 36cdc7dd1ca0902a2508eaa6d4883c9ab876e10d Mon Sep 17 00:00:00 2001 From: Matt Portune <59324545+mportune-bw@users.noreply.github.com> Date: Thu, 30 Apr 2020 16:47:29 -0400 Subject: [PATCH] Additional URI parsing fix (#865) * Additional URI parsing fix * name cleanup --- src/Android/Accessibility/AccessibilityHelpers.cs | 10 +++++----- src/Core/Utilities/CoreHelpers.cs | 12 ++++++------ 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/Android/Accessibility/AccessibilityHelpers.cs b/src/Android/Accessibility/AccessibilityHelpers.cs index 1cf6eae3a..0a7188445 100644 --- a/src/Android/Accessibility/AccessibilityHelpers.cs +++ b/src/Android/Accessibility/AccessibilityHelpers.cs @@ -161,18 +161,18 @@ namespace Bit.Droid.Accessibility uri = browser.GetUriFunction(addressNode.Text)?.Trim(); if (uri != null && uri.Contains(".")) { - if (Uri.TryCreate(uri, UriKind.Absolute, out var uri2)) - { - 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 uri2)) { return string.Concat("http://", uri); } } + if (Uri.TryCreate(uri, UriKind.Absolute, out var uri3)) + { + return uri; + } } return uri; } diff --git a/src/Core/Utilities/CoreHelpers.cs b/src/Core/Utilities/CoreHelpers.cs index 47f167d5f..1951b6f6c 100644 --- a/src/Core/Utilities/CoreHelpers.cs +++ b/src/Core/Utilities/CoreHelpers.cs @@ -85,18 +85,18 @@ namespace Bit.Core.Utilities { return null; } - if (Uri.TryCreate(uriString, UriKind.Absolute, out var 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 uri)) { - return uri2; + return uri; } } + if (Uri.TryCreate(uriString, UriKind.Absolute, out var uri2)) + { + return uri2; + } return null; }