docs: @Pure
  	public static URL addExtension(URL filename, String extension) {
  		if (filename != null && !hasExtension(filename, extension)) {
  			final String basename = largeBasename(filename);
  			if (!basename.isEmpty()) {
  				final StringBuilder buf = new StringBuilder(decodeHTMLEntities(
  						filename.getPath()).replaceFirst(Pattern.quote(URL_PATH_SEPARATOR)
  						+ "+$", "")); //$NON-NLS-1$ //$NON-NLS-2$
  				if (!"".equals(extension) && !extension.startsWith(EXTENSION_SEPARATOR)) { //$NON-NLS-1$
  					buf.append(EXTENSION_SEPARATOR);
  				}
  				buf.append(extension);
  				final String path = buf.toString();
  				try {
  					if (isJarURL(filename)) {
  						return new URL(
  								filename.getProtocol(),
  								filename.getHost(),
  								filename.getPort(),
  								path);
  					}
  					return new URI(
  							filename.getProtocol(),
  							filename.getUserInfo(),
  							filename.getHost(),
  							filename.getPort(),
  							path,
  							encodeHTMLEntities(filename.getQuery()),
  							filename.getRef()).toURL();
  				} catch (AssertionError e) {
  					throw e;
  				} catch (Throwable exception) {
  					//
  				}
  				try {
  					return new URL(
  							filename.getProtocol(),
  							filename.getHost(),
  							path);
  				} catch (AssertionError e) {
  					throw e;
  				} catch (Throwable exception) {
  					return null;
  				}
  			}
  		}
  		return filename;
  	}