From 4b3880056172d007fa3cba98829e4323833c1875 Mon Sep 17 00:00:00 2001 From: Soren Stoutner Date: Fri, 24 Mar 2017 15:40:03 -0700 Subject: [PATCH] Load `localhost` URLs, instead of searching for them. Fixes https://redmine.stoutner.com/issues/112. --- .idea/dictionaries/soren.xml | 1 + .../privacybrowser/activities/MainWebViewActivity.java | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.idea/dictionaries/soren.xml b/.idea/dictionaries/soren.xml index 780edc6d..29d93da7 100644 --- a/.idea/dictionaries/soren.xml +++ b/.idea/dictionaries/soren.xml @@ -57,6 +57,7 @@ knackstedt konqueror kufc + león linearlayout listview logins diff --git a/app/src/main/java/com/stoutner/privacybrowser/activities/MainWebViewActivity.java b/app/src/main/java/com/stoutner/privacybrowser/activities/MainWebViewActivity.java index a6d935df..5f82807c 100644 --- a/app/src/main/java/com/stoutner/privacybrowser/activities/MainWebViewActivity.java +++ b/app/src/main/java/com/stoutner/privacybrowser/activities/MainWebViewActivity.java @@ -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) { -- 2.45.2