core/src/main/java/com/digitalpebble/stormcrawler/util/URLUtil.java
private static URL fixEmbeddedParams(URL base, String target)
            throws MalformedURLException {

        // the target contains params information or the base doesn't then no
        // conversion necessary, return regular URL
        if (target.indexOf(';') >= 0 || base.toString().indexOf(';') == -1) {
            return new URL(base, target);
        }

        // get the base url and it params information
        String baseURL = base.toString();
        int startParams = baseURL.indexOf(';');
        String params = baseURL.substring(startParams);

        // if the target has a query string then put the params information
        // after
        // any path but before the query string, otherwise just append to the
        // path
        int startQS = target.indexOf('?');
        if (startQS >= 0) {
            target = target.substring(0, startQS) + params
                    + target.substring(startQS);
        } else {
            target += params;
        }

        return new URL(base, target);
    }
private static URL fixEmbeddedParams(URL base, String target)
            throws MalformedURLException {

        // the target contains params information or the base doesn't then no
        // conversion necessary, return regular URL
        if (target.indexOf(';') >= 0 || base.toString().indexOf(';') == -1) {
            return new URL(base, target);
        }

        // get the base url and it params information
        String baseURL = base.toString();
        int startParams = baseURL.indexOf(';');
        String params = baseURL.substring(startParams);

        // if the target has a query string then put the params information
        // after
        // any path but before the query string, otherwise just append to the
        // path
        int startQS = target.indexOf('?');
        if (startQS >= 0) {
            target = target.substring(0, startQS) + params
                    + target.substring(startQS);
        } else {
            target += params;
        }

        return new URL(base, target);
    }
private static URL fixEmbeddedParams ( URL base , String target ) throws MalformedURLException { // the target contains params information or the base doesn't then no // conversion necessary, return regular URL if ( target . indexOf ( ' ' ) >= 0 || base . toString ( ) . indexOf ( ' ' ) == - 1 ) { return new URL ( base , target ) ; } // get the base url and it params information String baseURL = base . toString ( ) ; int startParams = baseURL . indexOf ( ' ' ) ; String params = baseURL . substring ( startParams ) ; // if the target has a query string then put the params information // after // any path but before the query string, otherwise just append to the // path int startQS = target . indexOf ( ' ' ) ; if ( startQS >= 0 ) { target = target . substring ( 0 , startQS ) + params + target . substring ( startQS ) ; } else { target += params ; } return new URL ( base , target ) ; }
Handles cases where the url param information is encoded into the base
url as opposed to the target.
<p>
If the taget contains params (i.e. ';xxxx') information then the target
params information is assumed to be correct and any base params
information is ignored. If the base contains params information but the
tareget does not, then the params information is moved to the target
allowing it to be correctly determined by the java.net.URL class.

@param base
The base URL.
@param target
The target path from the base URL.

@return URL A URL with the params information correctly encoded.

@throws MalformedURLException
If the url is not a well formed URL.
Handles cases where the url param information is encoded into the base url as opposed to the target . <p > If the taget contains params ( i . e . ; xxxx ) information then the target params information is assumed to be correct and any base params information is ignored . If the base contains params information but the tareget does not then the params information is moved to the target allowing it to be correctly determined by the java . net . URL class .