]> gitweb.stoutner.com Git - PrivacyBrowserAndroid.git/blobdiff - app/src/main/java/com/stoutner/privacybrowser/activities/MainWebViewActivity.java
Load `localhost` URLs, instead of searching for them. Fixes https://redmine.stoutner...
[PrivacyBrowserAndroid.git] / app / src / main / java / com / stoutner / privacybrowser / activities / MainWebViewActivity.java
index a6d935df1f0b36bb50af2eda0e1a8ba15fe8beac..5f82807c68417b1954bf960b009bb777b25b4011 100644 (file)
@@ -1828,9 +1828,9 @@ public class MainWebViewActivity extends AppCompatActivity implements Navigation
         // Get the text from urlTextBox and convert it to a string.  trim() removes white spaces from the beginning and end of the string.
         String unformattedUrlString = urlTextBox.getText().toString().trim();
 
-        // Check to see if unformattedUrlString is a valid URL.  Otherwise, convert it into a Duck Duck Go search.
-        if (Patterns.WEB_URL.matcher(unformattedUrlString).matches()) {
-            // Add http:// at the beginning if it is missing.  Otherwise the app will segfault.
+        // Check to see if `unformattedUrlString` is a valid URL.  Otherwise, convert it into a search.
+        if ((Patterns.WEB_URL.matcher(unformattedUrlString).matches()) || (unformattedUrlString.contains("localhost"))) {
+            // Add `http://` at the beginning if it is missing.  Otherwise the app will segfault.
             if (!unformattedUrlString.startsWith("http")) {
                 unformattedUrlString = "http://" + unformattedUrlString;
             }
@@ -1838,7 +1838,7 @@ public class MainWebViewActivity extends AppCompatActivity implements Navigation
             // Initialize `unformattedUrl`.
             URL unformattedUrl = null;
 
-            // Convert unformattedUrlString to a URL, then to a URI, and then back to a string, which sanitizes the input and adds in any missing components.
+            // Convert `unformattedUrlString` to a `URL`, then to a `URI`, and then back to a `String`, which sanitizes the input and adds in any missing components.
             try {
                 unformattedUrl = new URL(unformattedUrlString);
             } catch (MalformedURLException e) {