static boolean isPrefixEqual ( String aUrlStr , String bUrlStr ) throws MalformedURLException { URL aUrl = new URL ( aUrlStr ) ; URL bUrl = new URL ( bUrlStr ) ; int aPort = aUrl . getPort ( ) ; int bPort = bUrl . getPort ( ) ; if ( aPort == - 1 && "https" . equals ( aUrl . getProtocol ( ) ) ) { // default port number for HTTPS aPort = 443 ; } if ( bPort == - 1 && "https" . equals ( bUrl . getProtocol ( ) ) ) { // default port number for HTTPS bPort = 443 ; } // no default port number for HTTP is supported. return aUrl . getHost ( ) . equalsIgnoreCase ( bUrl . getHost ( ) ) && aUrl . getProtocol ( ) . equalsIgnoreCase ( bUrl . getProtocol ( ) ) && aPort == bPort ; }
Verify if two input urls have the same protocol host and port .