OSDN Git Service

allow mixed-case schemes in user-defined URLs
authorCary Clark <cary@android.com>
Thu, 10 Sep 2009 17:34:44 +0000 (13:34 -0400)
committerCary Clark <cary@android.com>
Thu, 10 Sep 2009 21:09:49 +0000 (17:09 -0400)
Adjust the scheme to all lower case before fixing the URL. This
allows mixed-case entries in bookmarks to resolve to a conical
lower case URL.

src/com/android/browser/BrowserActivity.java

index bff8d04..7e0db56 100644 (file)
@@ -747,6 +747,24 @@ public class BrowserActivity extends Activity
     }
 
     /* package */ static String fixUrl(String inUrl) {
+        // FIXME: Converting the url to lower case
+        // duplicates functionality in smartUrlFilter().
+        // However, changing all current callers of fixUrl to
+        // call smartUrlFilter in addition may have unwanted
+        // consequences, and is deferred for now.
+        int colon = inUrl.indexOf(':');
+        boolean allLower = true;
+        for (int index = 0; index < colon; index++) {
+            char ch = inUrl.charAt(index);
+            if (!Character.isLetter(ch)) {
+                break;
+            }
+            allLower &= Character.isLowerCase(ch);
+            if (index == colon - 1 && !allLower) {
+                inUrl = inUrl.substring(0, colon).toLowerCase()
+                        + inUrl.substring(colon);
+            }
+        }
         if (inUrl.startsWith("http://") || inUrl.startsWith("https://"))
             return inUrl;
         if (inUrl.startsWith("http:") ||