Skip to content
This repository has been archived by the owner on Jul 22, 2024. It is now read-only.

Commit

Permalink
Let gecko choose protocol for addresses (#2923)
Browse files Browse the repository at this point in the history
Fixes #1453
  • Loading branch information
MortimerGoro authored Mar 5, 2020
1 parent 7acc7a7 commit 26b2418
Showing 1 changed file with 2 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -331,31 +331,10 @@ public UIButton getPopUpButton() {

public void handleURLEdit(String text) {
text = text.trim();
URI uri = null;
try {
boolean hasProtocol = text.contains("://");
String urlText = text;
// Detect when the protocol is missing from the URL.
// Look for a separated '.' in the text with no white spaces.
if (!hasProtocol && !urlText.contains(" ") && UrlUtils.isDomain(urlText)) {
urlText = "https://" + urlText;
hasProtocol = true;
} else if (!hasProtocol && !urlText.contains(" ") && UrlUtils.isIPUri(urlText)) {
String protocol = UrlUtils.isLocalIP(urlText) ? "http://" : "https://";
urlText = protocol + urlText;
hasProtocol = true;
}
if (hasProtocol) {
URL url = new URL(urlText);
uri = url.toURI();
}
}
catch (Exception ex) {
}

String url;
if (uri != null) {
url = uri.toString();
if ((UrlUtils.isDomain(text) || UrlUtils.isIPUri(text)) && !text.contains(" ")) {
url = text;
TelemetryWrapper.urlBarEvent(true);
GleanMetricsService.urlBarEvent(true);
} else if (text.startsWith("about:") || text.startsWith("resource://")) {
Expand Down

0 comments on commit 26b2418

Please sign in to comment.