Search in sources :

Example 21 with WebAddress

use of android.net.WebAddress in project android_frameworks_base by AOSPA.

the class WebAddressTest method testPathWithoutLeadingSlash.

// http://b/1011602
@SmallTest
public void testPathWithoutLeadingSlash() {
    WebAddress webAddress = new WebAddress("http://www.myspace.com?si=1");
    assertEquals("www.myspace.com", webAddress.getHost());
    assertEquals("/?si=1", webAddress.getPath());
}
Also used : WebAddress(android.net.WebAddress) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Example 22 with WebAddress

use of android.net.WebAddress in project android_frameworks_base by AOSPA.

the class URLUtil method guessUrl.

/**
     * Cleans up (if possible) user-entered web addresses
     */
public static String guessUrl(String inUrl) {
    String retVal = inUrl;
    WebAddress webAddress;
    if (TRACE)
        Log.v(LOGTAG, "guessURL before queueRequest: " + inUrl);
    if (inUrl.length() == 0)
        return inUrl;
    if (inUrl.startsWith("about:"))
        return inUrl;
    // Do not try to interpret data scheme URLs
    if (inUrl.startsWith("data:"))
        return inUrl;
    // Do not try to interpret file scheme URLs
    if (inUrl.startsWith("file:"))
        return inUrl;
    // Do not try to interpret javascript scheme URLs
    if (inUrl.startsWith("javascript:"))
        return inUrl;
    // bug 762454: strip period off end of url
    if (inUrl.endsWith(".") == true) {
        inUrl = inUrl.substring(0, inUrl.length() - 1);
    }
    try {
        webAddress = new WebAddress(inUrl);
    } catch (ParseException ex) {
        if (TRACE) {
            Log.v(LOGTAG, "smartUrlFilter: failed to parse url = " + inUrl);
        }
        return retVal;
    }
    // Check host
    if (webAddress.getHost().indexOf('.') == -1) {
        // no dot: user probably entered a bare domain.  try .com
        webAddress.setHost("www." + webAddress.getHost() + ".com");
    }
    return webAddress.toString();
}
Also used : WebAddress(android.net.WebAddress) ParseException(android.net.ParseException)

Example 23 with WebAddress

use of android.net.WebAddress in project android_frameworks_base by ResurrectionRemix.

the class URLUtil method guessUrl.

/**
     * Cleans up (if possible) user-entered web addresses
     */
public static String guessUrl(String inUrl) {
    String retVal = inUrl;
    WebAddress webAddress;
    if (TRACE)
        Log.v(LOGTAG, "guessURL before queueRequest: " + inUrl);
    if (inUrl.length() == 0)
        return inUrl;
    if (inUrl.startsWith("about:"))
        return inUrl;
    // Do not try to interpret data scheme URLs
    if (inUrl.startsWith("data:"))
        return inUrl;
    // Do not try to interpret file scheme URLs
    if (inUrl.startsWith("file:"))
        return inUrl;
    // Do not try to interpret javascript scheme URLs
    if (inUrl.startsWith("javascript:"))
        return inUrl;
    // bug 762454: strip period off end of url
    if (inUrl.endsWith(".") == true) {
        inUrl = inUrl.substring(0, inUrl.length() - 1);
    }
    try {
        webAddress = new WebAddress(inUrl);
    } catch (ParseException ex) {
        if (TRACE) {
            Log.v(LOGTAG, "smartUrlFilter: failed to parse url = " + inUrl);
        }
        return retVal;
    }
    // Check host
    if (webAddress.getHost().indexOf('.') == -1) {
        // no dot: user probably entered a bare domain.  try .com
        webAddress.setHost("www." + webAddress.getHost() + ".com");
    }
    return webAddress.toString();
}
Also used : WebAddress(android.net.WebAddress) ParseException(android.net.ParseException)

Example 24 with WebAddress

use of android.net.WebAddress in project android_frameworks_base by ResurrectionRemix.

the class WebAddressTest method testHostWithTrailingDot.

// http://b/2337042
@SmallTest
public void testHostWithTrailingDot() {
    WebAddress webAddress = new WebAddress("http://google.com./b/c/g");
    assertEquals("google.com.", webAddress.getHost());
    assertEquals("/b/c/g", webAddress.getPath());
}
Also used : WebAddress(android.net.WebAddress) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Example 25 with WebAddress

use of android.net.WebAddress in project android_frameworks_base by DirtyUnicorns.

the class WebAddressTest method testHostWithTrailingDot.

// http://b/2337042
@SmallTest
public void testHostWithTrailingDot() {
    WebAddress webAddress = new WebAddress("http://google.com./b/c/g");
    assertEquals("google.com.", webAddress.getHost());
    assertEquals("/b/c/g", webAddress.getPath());
}
Also used : WebAddress(android.net.WebAddress) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Aggregations

WebAddress (android.net.WebAddress)26 ParseException (android.net.ParseException)14 SmallTest (android.test.suitebuilder.annotation.SmallTest)12