static String truncatePath ( String path , String commonPrefix ) { final int nextSlash = path . indexOf ( ' ' , commonPrefix . length ( ) ) ; final int nextOpenCurly = path . indexOf ( ' ' , commonPrefix . length ( ) ) ; if ( nextSlash > 0 ) return path . substring ( 0 , nextSlash ) ; else if ( nextOpenCurly > 0 ) return path . substring ( 0 , nextOpenCurly ) ; else return path ; }
Truncate path to the completion of the segment ending with the common prefix