code: private List<String> getDomainsFromUrl(URL url) {
          String host = url.getHost();
          String[] paths = new String[] {};
          if (url.getPath() != null) {
              paths = url.getPath().split("/");
          }
          List<String> domains = new ArrayList<String>(paths.length + 1);
          StringBuilder relative = new StringBuilder().append("http://").append(host).append("/");
          domains.add(relative.toString());
          for (String path : paths) {
              if (path.length() > 0) {
                  relative.append(path).append("/");
                  domains.add(relative.toString());
              }
          }
          return domains;
      }
docs: Gets the list of domains associated to a URL.
  
  @param url
  @return List of domains as strings