Browse Source

Improved comment readability in IDE editor

master
Anthony Restaino 10 years ago
parent
commit
fbd74df422
  1. 46
      src/acr/browser/lightning/WebAddress.java

46
src/acr/browser/lightning/WebAddress.java

@ -11,15 +11,15 @@ import static android.util.Patterns.GOOD_IRI_CHAR;
/** /**
* {@hide} * {@hide}
* *
* Web Address Parser * Web Address Parser
* *
* This is called WebAddress, rather than URL or URI, because it attempts to parse the stuff that a user will actually * This is called WebAddress, rather than URL or URI, because it attempts to
* type into a browser address widget. * parse the stuff that a user will actually type into a browser address widget.
* *
* Unlike java.net.uri, this parser will not choke on URIs missing schemes. It will only throw a ParseException if the * Unlike java.net.uri, this parser will not choke on URIs missing schemes. It
* input is really hosed. * will only throw a ParseException if the input is really hosed.
* *
* If given an https scheme but no port, fills in port * If given an https scheme but no port, fills in port
*/ */
public class WebAddress { public class WebAddress {
@ -44,13 +44,14 @@ public class WebAddress {
static final int MATCH_GROUP_PATH = 5; static final int MATCH_GROUP_PATH = 5;
static Pattern sAddressPattern = Pattern.compile( static Pattern sAddressPattern = Pattern
/* scheme */ "(?:(http|https|file)\\:\\/\\/)?" + .compile(
/* authority */ "(?:([-A-Za-z0-9$_.+!*'(),;?&=]+(?:\\:[-A-Za-z0-9$_.+!*'(),;?&=]+)?)@)?" + /* scheme */"(?:(http|https|file)\\:\\/\\/)?" +
/* host */ "([" + GOOD_IRI_CHAR + "%_-][" + GOOD_IRI_CHAR + "%_\\.-]*|\\[[0-9a-fA-F:\\.]+\\])?" + /* authority */"(?:([-A-Za-z0-9$_.+!*'(),;?&=]+(?:\\:[-A-Za-z0-9$_.+!*'(),;?&=]+)?)@)?" +
/* port */ "(?:\\:([0-9]*))?" + /* host */"([" + GOOD_IRI_CHAR + "%_-][" + GOOD_IRI_CHAR + "%_\\.-]*|\\[[0-9a-fA-F:\\.]+\\])?" +
/* path */ "(\\/?[^#]*)?" + /* port */"(?:\\:([0-9]*))?" +
/* anchor */ ".*", Pattern.CASE_INSENSITIVE); /* path */"(\\/?[^#]*)?" +
/* anchor */".*", Pattern.CASE_INSENSITIVE);
/** /**
* parses given uriString. * parses given uriString.
@ -94,8 +95,10 @@ public class WebAddress {
} }
t = m.group(MATCH_GROUP_PATH); t = m.group(MATCH_GROUP_PATH);
if (t != null && t.length() > 0) { if (t != null && t.length() > 0) {
/* handle busted myspace frontpage redirect with /*
missing initial "/" */ * handle busted myspace frontpage redirect with missing initial
* "/"
*/
if (t.charAt(0) == '/') { if (t.charAt(0) == '/') {
mPath = t; mPath = t;
} else { } else {
@ -108,8 +111,9 @@ public class WebAddress {
throw new Exception(); throw new Exception();
} }
/* Get port from scheme or scheme from port, if necessary and /*
possible */ * Get port from scheme or scheme from port, if necessary and possible
*/
if (mPort == 443 && mScheme.equals("")) { if (mPort == 443 && mScheme.equals("")) {
mScheme = "https"; mScheme = "https";
} else if (mPort == -1) { } else if (mPort == -1) {
@ -127,8 +131,8 @@ public class WebAddress {
@Override @Override
public String toString() { public String toString() {
String port = ""; String port = "";
if ((mPort != 443 && mScheme.equals("https")) || if ((mPort != 443 && mScheme.equals("https"))
(mPort != 80 && mScheme.equals("http"))) { || (mPort != 80 && mScheme.equals("http"))) {
port = ":" + Integer.toString(mPort); port = ":" + Integer.toString(mPort);
} }
String authInfo = ""; String authInfo = "";

Loading…
Cancel
Save