From: Soren Stoutner Date: Fri, 24 Mar 2017 22:40:03 +0000 (-0700) Subject: Load `localhost` URLs, instead of searching for them. Fixes https://redmine.stoutner... X-Git-Tag: v2.1~1 X-Git-Url: https://gitweb.stoutner.com/?a=commitdiff_plain;h=4b3880056172d007fa3cba98829e4323833c1875;p=PrivacyBrowserAndroid.git Load `localhost` URLs, instead of searching for them. Fixes https://redmine.stoutner.com/issues/112. --- 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) {