@VisibleForTesting public static Pair<String,String> splitPathFromUrlDisplayText(String displayText){
  int pathSearchOffset=0;
  Uri uri=Uri.parse(displayText);
  String scheme=uri.getScheme();
  if (!TextUtils.isEmpty(scheme)) {
    if (UNSUPPORTED_SCHEMES_TO_SPLIT.contains(scheme)) {
      return Pair.create(displayText,null);
    }
 else     if (ACCEPTED_SCHEMES.contains(scheme)) {
      for (pathSearchOffset=scheme.length(); pathSearchOffset < displayText.length(); pathSearchOffset++) {
        char c=displayText.charAt(pathSearchOffset);
        if (c != ':' && c != '/')         break;
      }
    }
  }
  int pathOffset=-1;
  if (pathSearchOffset < displayText.length()) {
    pathOffset=displayText.indexOf('/',pathSearchOffset);
  }
  if (pathOffset != -1) {
    String prePathText=displayText.substring(0,pathOffset);
    String pathText=pathOffset == displayText.length() - 1 ? null : displayText.substring(pathOffset);
    return Pair.create(prePathText,pathText);
  }
  return Pair.create(displayText,null);
}

@ VisibleForTesting public static Pair < String , String > splitPathFromUrlDisplayText ( String displayText ) { int pathSearchOffset = 0 ; Uri uri = Uri . parse ( displayText ) ; String scheme = uri . getScheme ( ) ; if ( ! TextUtils . isEmpty ( scheme ) ) { if ( UNSUPPORTED_SCHEMES_TO_SPLIT . contains ( scheme ) ) { return Pair . create ( displayText , null ) ; } else if ( ACCEPTED_SCHEMES . contains ( scheme ) ) { for ( pathSearchOffset = scheme . length ( ) ; pathSearchOffset < displayText . length ( ) ; pathSearchOffset ++ ) { char c = displayText . charAt ( pathSearchOffset ) ; if ( c != ':' && c != '/' ) break ; } } } int pathOffset = - 1 ; if ( pathSearchOffset < displayText . length ( ) ) { pathOffset = displayText . indexOf ( '/' , pathSearchOffset ) ; } if ( pathOffset != - 1 ) { String prePathText = displayText . substring ( 0 , pathOffset ) ; String pathText = pathOffset == displayText . length ( ) - 1 ? null : displayText . substring ( pathOffset ) ; return Pair . create ( prePathText , pathText ) ; } return Pair . create ( displayText , null ) ; }
given the url display text , this will remove any path portion contained within .
