code: protected String removeQueryAndFragment(String url) {
          if (url == null) {
              return url;
          }
          String cleanUrl = url;
  
          int queryIndex = url.indexOf("?");
          int fragmentIndex = url.indexOf("#");
          if (queryIndex > 0) {
              if (fragmentIndex > 0 && fragmentIndex < queryIndex) {
                  // Found fragment before the query string; remove everything after fragment
                  cleanUrl = url.substring(0, fragmentIndex);
              } else {
                  // Didn't find fragment or fragment is after query string; remove everything after query string
                  cleanUrl = url.substring(0, queryIndex);
              }
          } else if (fragmentIndex > 0) {
              // No query string, but did find a fragment
              cleanUrl = url.substring(0, fragmentIndex);
          }
          return cleanUrl;
      }
docs: Removes any query string and/or fragment in the provided string, if present, and returns the new string.
  
  @param url
  @return