public String getSanitizedUrl ( ) { if ( url . startsWith ( "http://" ) && ( url . endsWith ( ":80" ) || url . contains ( ":80/" ) ) ) { return url . replaceAll ( "\\?.*" , "" ) . replaceAll ( ":80" , "" ) ; } else if ( url . startsWith ( "https://" ) && ( url . endsWith ( ":443" ) || url . contains ( ":443/" ) ) ) { return url . replaceAll ( "\\?.*" , "" ) . replaceAll ( ":443" , "" ) ; } else { return url . replaceAll ( "\\?.*" , "" ) ; } }
Returns the URL without the port and the query string part .