docs: public static String resolve(final String resolveBasePath, final String relativePath) {
          // See: http://stackoverflow.com/a/17870390/3950982
          // https://weblogs.java.net/blog/kohsuke/archive/2007/04/how_to_convert.html
  
          if (relativePath == null || relativePath.isEmpty()) {
              return resolveBasePath == null ? "" : resolveBasePath;
          }
  
          String prefix = "";
          boolean isAbsolutePath = false;
          boolean isFileOrJarURL = false;
          int startIdx = 0;
          if (relativePath.regionMatches(true, startIdx, "jar:", 0, 4)) {
              // "jar:" prefix can be stripped
              startIdx += 4;
              isFileOrJarURL = true;
          }
          if (relativePath.regionMatches(true, startIdx, "http://", 0, 7)) {
              // Detect http://
              startIdx += 7;
              // Force protocol name to lowercase
              prefix = "http://";
              // Treat the part after the protocol as an absolute path, so the domain is not treated as a directory
              // relative to the current directory.
              isAbsolutePath = true;
              // Don't un-escape percent encoding etc.
          } else if (relativePath.regionMatches(true, startIdx, "https://", 0, 8)) {
              // Detect https://
              startIdx += 8;
              prefix = "https://";
              isAbsolutePath = true;
          } else if (relativePath.regionMatches(true, startIdx, "jrt:", 0, 5)) {
              // Detect jrt:
              startIdx += 4;
              prefix = "jrt:";
              isAbsolutePath = true;
          } else if (relativePath.regionMatches(true, startIdx, "file:", 0, 5)) {
              // Strip off any "file:" prefix from relative path
              startIdx += 5;
              if (WINDOWS) {
                  if (relativePath.startsWith("\\\\\\\\", startIdx) || relativePath.startsWith("////", startIdx)) {
                      // Windows UNC URL
                      startIdx += 4;
                      prefix = "//";
                      isAbsolutePath = true;
                  } else {
                      if (relativePath.startsWith("\\\\", startIdx)) {
                          startIdx += 2;
                      }
                  }
              }
              if (relativePath.startsWith("//", startIdx)) {
                  startIdx += 2;
              }
              isFileOrJarURL = true;
          } else if (WINDOWS && (relativePath.startsWith("//") || relativePath.startsWith("\\\\"))) {
              // Windows UNC path
              startIdx += 2;
              prefix = "//";
              isAbsolutePath = true;
          }
          // Handle Windows paths starting with a drive designation as an absolute path
          if (WINDOWS) {
              if (relativePath.length() - startIdx > 2 && Character.isLetter(relativePath.charAt(startIdx))
                      && relativePath.charAt(startIdx + 1) == ':') {
                  isAbsolutePath = true;
              } else if (relativePath.length() - startIdx > 3
                      && (relativePath.charAt(startIdx) == '/' || relativePath.charAt(startIdx) == '\\')
                      && Character.isLetter(relativePath.charAt(startIdx + 1))
                      && relativePath.charAt(startIdx + 2) == ':') {
                  isAbsolutePath = true;
                  startIdx++;
              }
          }
          // Catch-all for paths starting with separator
          if (relativePath.length() - startIdx > 1
                  && (relativePath.charAt(startIdx) == '/' || relativePath.charAt(startIdx) == '\\')) {
              isAbsolutePath = true;
          }
  
          // Normalize the path, then add any UNC or URL prefix
          String pathStr = normalizePath(startIdx == 0 ? relativePath : relativePath.substring(startIdx),
                  isFileOrJarURL);
          if (!pathStr.equals("/")) {
              // Remove any "!/" on end of URL
              if (pathStr.endsWith("/")) {
                  pathStr = pathStr.substring(0, pathStr.length() - 1);
              }
              if (pathStr.endsWith("!")) {
                  pathStr = pathStr.substring(0, pathStr.length() - 1);
              }
              if (pathStr.endsWith("/")) {
                  pathStr = pathStr.substring(0, pathStr.length() - 1);
              }
              if (pathStr.isEmpty()) {
                  pathStr = "/";
              }
          }
  
          // Sanitize path (resolve ".." sections, collapse "//" double separators, etc.)
          String pathResolved;
          if (isAbsolutePath || resolveBasePath == null || resolveBasePath.isEmpty()) {
              // There is no base path to resolve against, or path is an absolute path or http(s):// URL
              // (ignore the base path)
              pathResolved = FileUtils.sanitizeEntryPath(pathStr, /* removeInitialSlash = */ false);
          } else {
              // Path is a relative path -- resolve it relative to the base path
              pathResolved = FileUtils.sanitizeEntryPath(
                      resolveBasePath + (resolveBasePath.endsWith("/") ? "" : "/") + pathStr,
                      /* removeInitialSlash = */ false);
          }
  
          // Add any prefix back, e.g. "https://"
          return prefix.isEmpty() ? pathResolved : prefix + pathResolved;
      }