public static String normalizeURLPath ( final String urlPath ) { String urlPathNormalized = urlPath ; if ( ! urlPathNormalized . startsWith ( "jrt:" ) && ! urlPathNormalized . startsWith ( "http://" ) && ! urlPathNormalized . startsWith ( "https://" ) ) { // Any URL with the "jar:" prefix must have "/" after any "!" urlPathNormalized = urlPathNormalized . replace ( "/!" , "!" ) . replace ( "!/" , "!" ) . replace ( "!" , "!/" ) ; // Prepend "jar:file:" if ( ! urlPathNormalized . startsWith ( "file:" ) && ! urlPathNormalized . startsWith ( "jar:" ) ) { urlPathNormalized = "file:" + urlPathNormalized ; } if ( urlPathNormalized . contains ( "!" ) && ! urlPathNormalized . startsWith ( "jar:" ) ) { urlPathNormalized = "jar:" + urlPathNormalized ; } } return encodePath ( urlPathNormalized ) ; }
Normalize a URL path so that it can be fed into the URL or URI constructor .