static String removeExtraneousSlashes(String s) {
    int lastNonSlash = NON_SLASH_MATCHER.lastIndexIn(s);
    if (lastNonSlash != -1) {
      s = s.substring(0, lastNonSlash + 1);
    }

    return SLASH_MATCHER.collapseFrom(s, '/');
  }
static String removeExtraneousSlashes ( String s ) { int lastNonSlash = NON_SLASH_MATCHER . lastIndexIn ( s ) ; if ( lastNonSlash != - 1 ) { s = s . substring ( 0 , lastNonSlash + 1 ) ; } return SLASH_MATCHER . collapseFrom ( s , '/' ) ; }
Removes extra slashes from a path.  Leading slash is preserved, trailing
slash is stripped, and any runs of more than one slash in the middle is
replaced by a single slash.