code: public void normalizeByScheme() {
          String rURI = toString();
          String scheme = uri.getScheme();
          String authority = uri.getAuthority();
          String host = uri.getHost();
          int port = uri.getPort();
          String path = uri.getPath();
  
          if (port == defaultPort(scheme)) {
              rURI = rURI.replaceFirst(":" + port, "");
              try {
                  uri = new URI(rURI);
              } catch (URISyntaxException e) {
                  // This should never be reached
                  e.printStackTrace();
              }
          }
  
          if (port == -1 && authority != null && authority.endsWith(":")) {
              rURI = rURI.replaceFirst(authority, authority.substring(0, authority.length() -1));
              try {
                  uri = new URI(rURI);
              } catch (URISyntaxException e) {
                  // This should never be reached
                  e.printStackTrace();
              }
          }
  
          if (path == null || path.length() == 0) {
              if (host != null) {
                  rURI = rURI.replaceFirst(host, host + '/');
              } else {
                  rURI = rURI.replaceFirst(authority, authority + '/');
              }
              uri = URI.create(rURI);
          }
      }
docs: Scheme-Based Normalization
  @see "RFC3986 6.2.3"