public static @Nullable URL internProtocol(@NotNull URL url) {
    String protocol = url.getProtocol();
    boolean interned = false;
    if ("file".equals(protocol) || "jar".equals(protocol)) {
      protocol = protocol.intern();
      interned = true;
    }
    String host = url.getHost();
    if (host != null && host.isEmpty()) {
      host = "";
      interned = true;
    }
    try {
      if (interned) {
        url = new URL(protocol, host, url.getPort(), url.getFile());
      }
      return url;
    }
    catch (MalformedURLException e) {
      //noinspection CallToPrintStackTrace
      e.printStackTrace();
      return null;
    }
  }
public static @Nullable URL internProtocol(@NotNull URL url)