public String contextualizeUrl(final String url, String flags) {
		// if we get an empty string, just return it:
		if (url.length() == 0) {
			return url;
		}
		
		if (url.startsWith(JAVASCRIPT_PREFIX) || url.startsWith(MAILTO_PREFIX) || url.startsWith(ANCHOR_PREFIX)) {
	    	return url;
	    }
	    // XXX duplicated check for MAILTO_PREFIX??
		if (url.startsWith(DATA_PREFIX) || url.startsWith(MAILTO_PREFIX)) {
	    	return url;
	    }

		// don't rewrite path-relative urls. For
		// https://webarchive.jira.com/browse/ARI-3985
		String trimmedUrl = url.trim();

		if (!trimmedUrl.startsWith("http://") &&
				!trimmedUrl.startsWith("https://") &&
				!trimmedUrl.startsWith("ftp://") &&
				!trimmedUrl.startsWith("ftps://") &&
				!trimmedUrl.startsWith("//") &&
				!trimmedUrl.startsWith("http:\\\\/\\\\/") &&
				!trimmedUrl.startsWith("http\\\\u00253A\\\\u00252F\\\\u00252F") &&
				!trimmedUrl.startsWith("https:\\\\/\\\\/") &&
				!trimmedUrl
					.startsWith("https\\\\u00253A\\\\u00252F\\\\u00252F") &&
				!trimmedUrl.startsWith("ftp:\\\\/\\\\/") &&
				!trimmedUrl.startsWith("ftp\\\\u00253A\\\\u00252F\\\\u00252F") &&
				!trimmedUrl.startsWith("ftps:\\\\/\\\\/") &&
				!trimmedUrl.startsWith("ftps\\\\u00253A\\\\u00252F\\\\u00252F") &&
				!trimmedUrl.startsWith("http:\\/\\/") &&
				!trimmedUrl.startsWith("https:\\/\\/") &&
				!trimmedUrl.startsWith("ftp:\\/\\/") &&
				!trimmedUrl.startsWith("ftps:\\/\\/") &&
				!trimmedUrl.startsWith("/") &&
				!trimmedUrl.startsWith(".")) {
			return url;
		}

	    // first make url into absolute, taking BASE into account.
		// (this also removes escaping: ex. "https:\/\/" -> "https://")
	    String absurl = super.contextualizeUrl(url);
	    if (!isRewriteSupported(absurl)) {
	    	return url;
	    }
	    // XXX do this in getConverter
		if (flags == null) {
	    	flags = "";
	    }
	    ResultURIConverter converter = getConverter(flags);
		return converter.makeReplayURI(datespec, absurl);
	}
public String contextualizeUrl ( final String url , String flags ) { if ( url . length ( ) == 0 ) { return url ; } if ( url . startsWith ( JAVASCRIPT_PREFIX ) || url . startsWith ( MAILTO_PREFIX ) || url . startsWith ( ANCHOR_PREFIX ) ) { return url ; } if ( url . startsWith ( DATA_PREFIX ) || url . startsWith ( MAILTO_PREFIX ) ) { return url ; } String trimmedUrl = url . trim ( ) ; if ( ! trimmedUrl . startsWith ( "http://" ) && ! trimmedUrl . startsWith ( "https://" ) && ! trimmedUrl . startsWith ( "ftp://" ) && ! trimmedUrl . startsWith ( "ftps://" ) && ! trimmedUrl . startsWith ( "//" ) && ! trimmedUrl . startsWith ( "http:\\\\/\\\\/" ) && ! trimmedUrl . startsWith ( "http\\\\u00253A\\\\u00252F\\\\u00252F" ) && ! trimmedUrl . startsWith ( "https:\\\\/\\\\/" ) && ! trimmedUrl . startsWith ( "https\\\\u00253A\\\\u00252F\\\\u00252F" ) && ! trimmedUrl . startsWith ( "ftp:\\\\/\\\\/" ) && ! trimmedUrl . startsWith ( "ftp\\\\u00253A\\\\u00252F\\\\u00252F" ) && ! trimmedUrl . startsWith ( "ftps:\\\\/\\\\/" ) && ! trimmedUrl . startsWith ( "ftps\\\\u00253A\\\\u00252F\\\\u00252F" ) && ! trimmedUrl . startsWith ( "http:\\/\\/" ) && ! trimmedUrl . startsWith ( "https:\\/\\/" ) && ! trimmedUrl . startsWith ( "ftp:\\/\\/" ) && ! trimmedUrl . startsWith ( "ftps:\\/\\/" ) && ! trimmedUrl . startsWith ( "/" ) && ! trimmedUrl . startsWith ( "." ) ) { return url ; } String absurl = super . contextualizeUrl ( url ) ; if ( ! isRewriteSupported ( absurl ) ) { return url ; } if ( flags == null ) { flags = "" ; } ResultURIConverter converter = getConverter ( flags ) ; return converter . makeReplayURI ( datespec , absurl ) ; }
Rewrite URL {@code url} in accordance with current replay mode, taking
replay context {@code flags} into account.
<p>It is important to return the same String object {@code url} if no rewrite
is necessary, so that caller can short-circuit to avoid expensive String operations.</p>
@param url URL, candidate for rewrite. may contain escaping. must not be {@code null}.
@param flags <em>context</em> designator, such as {@code "cs_"}. can be {@code null}.
@return rewrittenURL, or {@code url} if no rewrite is necessary. never {@code null}.