docs: @Pure
  	@SuppressWarnings("checkstyle:npathcomplexity")
  	public static URL dirname(URL filename) {
  		if (filename == null) {
  			return null;
  		}
  
  		URL prefix = null;
  		String path;
  		if (isJarURL(filename)) {
  			prefix = getJarURL(filename);
  			path = fromFileStandardToURLStandard(getJarFile(filename));
  		} else {
  			path = filename.getPath();
  		}
  
  		if ("".equals(path)) { //$NON-NLS-1$
  			return null;
  		}
  
  		int idx = path.lastIndexOf(URL_PATH_SEPARATOR_CHAR);
  		if (idx == path.length() - 1) {
  			idx = path.lastIndexOf(URL_PATH_SEPARATOR_CHAR, path.length() - 2);
  		}
  
  		if (idx < 0) {
  			if (URISchemeType.getSchemeType(filename).isFileBasedScheme()) {
  				path = CURRENT_DIRECTORY;
  			} else {
  				path = URL_PATH_SEPARATOR;
  			}
  		} else {
  			path = path.substring(0, idx + 1);
  		}
  
  		try {
  			if (prefix != null) {
  				return toJarURL(prefix, path);
  			}
  			return new URI(filename.getProtocol(),
  					filename.getUserInfo(),
  					filename.getHost(),
  					filename.getPort(),
  					decodeHTMLEntities(path),
  					null,
  					null).toURL();
  		} catch (Throwable exception) {
  			//
  		}
  
  		try {
  			return new URL(
  					filename.getProtocol(),
  					filename.getHost(),
  					path);
  		} catch (Throwable exception) {
  			//
  		}
  		return null;
  	}