src/main/java/org/owasp/url/Scheme.java
public PartRanges decompose(
      SchemeLookupTable schemes,
      String schemeSpecificPart, int left, int right) {
    PartRanges.Builder b = new PartRanges.Builder();

    if (isHierarchical) {
      int cursor = left;
      if (cursor + 2 < right
          && schemeSpecificPart.charAt(cursor) == '/'
          && schemeSpecificPart.charAt(cursor + 1) == '/') {
        cursor += 2;
        int authorityLeft = cursor;

        for (; cursor < right; ++cursor) {
          char ch = schemeSpecificPart.charAt(cursor);
          if (ch == '/' || ch == '?' || ch == '#') {
            break;
          }
        }
        b.withAuthority(authorityLeft, cursor);
      }

      int pathLeft = cursor;
      for (; cursor < right; ++cursor) {
        char ch = schemeSpecificPart.charAt(cursor);
        if (ch == '?' || ch == '#') {
          break;
        }
      }
      b.withPath(pathLeft, cursor);

      if (cursor < right && schemeSpecificPart.charAt(cursor) == '?') {
        int queryLeft = cursor;
        for (; cursor < right; ++cursor) {
          char ch = schemeSpecificPart.charAt(cursor);
          if (ch == '#') {
            break;
          }
        }
        b.withQuery(queryLeft, cursor);
      }

      if (cursor < right) {
        Preconditions.checkState(schemeSpecificPart.charAt(cursor) == '#');
        b.withFragment(cursor, right);
      }
    } else {
      int hash = -1;
      for (int i = left; i < right; ++i) {
        if (schemeSpecificPart.charAt(i) == '#') {
          hash = i;
          break;
        }
      }
      b.withContent(left, hash >= 0 ? hash : right);
      if (hash >= 0) {
        b.withFragment(hash, right);
      }
    }
    return b.build();
  }
/**
   * Identifies ranges of structures within the URL.
   *
   * <p>This method and all overrides must produce equivalent output given
   * the same inputs.
   *
   * @param schemes may be used to further decompose when a URLs embeds
   *     other URLs in its scheme specific part.
   * @param left The leftmost character (inclusive) of the scheme specific
   *     part.
   * @param right The rightmost character (exclusive) of the scheme specific
   *     part.
   * @return null if the scheme specific part is not well-formed.
   */
Identifies ranges of structures within the URL.
This method and all overrides must produce equivalent output given
the same inputs.

@param schemes may be used to further decompose when a URLs embeds
other URLs in its scheme specific part.
@param left The leftmost character (inclusive) of the scheme specific
part.
@param right The rightmost character (exclusive) of the scheme specific
part.
@return null if the scheme specific part is not well-formed.
Identifies ranges of structures within the URL . This method and all overrides must produce equivalent output given the same inputs . @param schemes may be used to further decompose when a URLs embeds other URLs in its scheme specific part . @param left The leftmost character ( inclusive ) of the scheme specific part . @param right The rightmost character ( exclusive ) of the scheme specific part . @return null if the scheme specific part is not well - formed .
public PartRanges decompose(
      SchemeLookupTable schemes,
      String schemeSpecificPart, int left, int right) {
    PartRanges.Builder b = new PartRanges.Builder();
    if (isHierarchical) {
      int cursor = left;
      if (cursor + 2 < right
          && schemeSpecificPart.charAt(cursor) == '/'
          && schemeSpecificPart.charAt(cursor + 1) == '/') {
        cursor += 2;
        int authorityLeft = cursor;
        for (; cursor < right; ++cursor) {
          char ch = schemeSpecificPart.charAt(cursor);
          if (ch == '/' || ch == '?' || ch == '#') {
            break;
          }
        }
        b.withAuthority(authorityLeft, cursor);
      }
      int pathLeft = cursor;
      for (; cursor < right; ++cursor) {
        char ch = schemeSpecificPart.charAt(cursor);
        if (ch == '?' || ch == '#') {
          break;
        }
      }
      b.withPath(pathLeft, cursor);
      if (cursor < right && schemeSpecificPart.charAt(cursor) == '?') {
        int queryLeft = cursor;
        for (; cursor < right; ++cursor) {
          char ch = schemeSpecificPart.charAt(cursor);
          if (ch == '#') {
            break;
          }
        }
        b.withQuery(queryLeft, cursor);
      }
      if (cursor < right) {
        Preconditions.checkState(schemeSpecificPart.charAt(cursor) == '#');
        b.withFragment(cursor, right);
      }
    } else {
      int hash = -1;
      for (int i = left; i < right; ++i) {
        if (schemeSpecificPart.charAt(i) == '#') {
          hash = i;
          break;
        }
      }
      b.withContent(left, hash >= 0 ? hash : right);
      if (hash >= 0) {
        b.withFragment(hash, right);
      }
    }
    return b.build();
  }
public PartRanges decompose ( SchemeLookupTable schemes , String schemeSpecificPart , int left , int right ) { PartRanges . Builder b = new PartRanges . Builder ( ) ; if ( isHierarchical ) { int cursor = left ; if ( cursor + 2 < right && schemeSpecificPart . charAt ( cursor ) == '/' && schemeSpecificPart . charAt ( cursor + 1 ) == '/' ) { cursor += 2 ; int authorityLeft = cursor ; for ( ; cursor < right ; ++ cursor ) { char ch = schemeSpecificPart . charAt ( cursor ) ; if ( ch == '/' || ch == '?' || ch == '#' ) { break ; } } b . withAuthority ( authorityLeft , cursor ) ; } int pathLeft = cursor ; for ( ; cursor < right ; ++ cursor ) { char ch = schemeSpecificPart . charAt ( cursor ) ; if ( ch == '?' || ch == '#' ) { break ; } } b . withPath ( pathLeft , cursor ) ; if ( cursor < right && schemeSpecificPart . charAt ( cursor ) == '?' ) { int queryLeft = cursor ; for ( ; cursor < right ; ++ cursor ) { char ch = schemeSpecificPart . charAt ( cursor ) ; if ( ch == '#' ) { break ; } } b . withQuery ( queryLeft , cursor ) ; } if ( cursor < right ) { Preconditions . checkState ( schemeSpecificPart . charAt ( cursor ) == '#' ) ; b . withFragment ( cursor , right ) ; } } else { int hash = - 1 ; for ( int i = left ; i < right ; ++ i ) { if ( schemeSpecificPart . charAt ( i ) == '#' ) { hash = i ; break ; } } b . withContent ( left , hash >= 0 ? hash : right ) ; if ( hash >= 0 ) { b . withFragment ( hash , right ) ; } } return b . build ( ) ; }
Identifies ranges of structures within the URL.
Identifies ranges of structures within the URL .