question: public static String escape ( String string ) { if ( string == null || string . equals ( "" ) ) { return string ; } String prefix = "" ; if ( string . indexOf ( "://" ) != - 1 ) { prefix = string . substring ( 0 , string . indexOf ( "://" ) + 3 ) ; string = string . replaceFirst ( prefix , "" ) ; } string = string . replaceAll ( "\\\\" , "/" ) ; if ( string . startsWith ( "//" ) ) { string = "/" + string . replaceAll ( "/+" , "/" ) ; } else { string = string . replaceAll ( "/+" , "/" ) ; } return prefix . concat ( string ) ; }
target:  Escapes double slashes (//) and replace all backslashes (\) with slashes (/). Additionally preserves UNC paths.