docs: private static Url resolveUrl(final Url baseUrl, final String relativeUrl) {
          final Url url = parseUrl(relativeUrl);
          // Step 1: The base URL is established according to the rules of
          //         Section 3.  If the base URL is the empty string (unknown),
          //         the embedded URL is interpreted as an absolute URL and
          //         we are done.
          if (baseUrl == null) {
              return url;
          }
          // Step 2: Both the base and embedded URLs are parsed into their
          //         component parts as described in Section 2.4.
          //      a) If the embedded URL is entirely empty, it inherits the
          //         entire base URL (i.e., is set equal to the base URL)
          //         and we are done.
          if (relativeUrl.isEmpty()) {
              return new Url(baseUrl);
          }
          //      b) If the embedded URL starts with a scheme name, it is
          //         interpreted as an absolute URL and we are done.
          if (url.scheme != null) {
              return url;
          }
          //      c) Otherwise, the embedded URL inherits the scheme of
          //         the base URL.
          url.scheme = baseUrl.scheme;
          // Step 3: If the embedded URL's <net_loc> is non-empty, we skip to
          //         Step 7.  Otherwise, the embedded URL inherits the <net_loc>
          //         (if any) of the base URL.
          if (url.location != null) {
              return url;
          }
          url.location = baseUrl.location;
          // Step 4: If the embedded URL path is preceded by a slash "/", the
          //         path is not relative and we skip to Step 7.
          if ((url.path != null) && ((!url.path.isEmpty()) && (url.path.charAt(0) == '/'))) {
              url.path = removeLeadingSlashPoints(url.path);
              return url;
          }
          // Step 5: If the embedded URL path is empty (and not preceded by a
          //         slash), then the embedded URL inherits the base URL path,
          //         and
          if (url.path == null) {
              url.path = baseUrl.path;
              //  a) if the embedded URL's <params> is non-empty, we skip to
              //     step 7; otherwise, it inherits the <params> of the base
              //     URL (if any) and
              if (url.parameters != null) {
                  return url;
              }
              url.parameters = baseUrl.parameters;
              //  b) if the embedded URL's <query> is non-empty, we skip to
              //     step 7; otherwise, it inherits the <query> of the base
              //     URL (if any) and we skip to step 7.
              if (url.query != null) {
                  return url;
              }
              url.query = baseUrl.query;
              return url;
          }
          // Step 6: The last segment of the base URL's path (anything
          //         following the rightmost slash "/", or the entire path if no
          //         slash is present) is removed and the embedded URL's path is
          //         appended in its place.  The following operations are
          //         then applied, in order, to the new path:
          final String basePath = baseUrl.path;
          String path = "";
  
          if (basePath != null) {
              final int lastSlashIndex = basePath.lastIndexOf('/');
  
              if (lastSlashIndex >= 0) {
                  path = basePath.substring(0, lastSlashIndex + 1);
              }
          } else {
              path = "/";
          }
          path = path.concat(url.path);
          //      a) All occurrences of "./", where "." is a complete path
          //         segment, are removed.
          int pathSegmentIndex;
  
          while ((pathSegmentIndex = path.indexOf("/./")) >= 0) {
              path = path.substring(0, pathSegmentIndex + 1)
                         .concat(path.substring(pathSegmentIndex + 3));
          }
          //      b) If the path ends with "." as a complete path segment,
          //         that "." is removed.
          if (path.endsWith("/.")) {
              path = path.substring(0, path.length() - 1);
          }
          //      c) All occurrences of "<segment>/../", where <segment> is a
          //         complete path segment not equal to "..", are removed.
          //         Removal of these path segments is performed iteratively,
          //         removing the leftmost matching pattern on each iteration,
          //         until no matching pattern remains.
          while ((pathSegmentIndex = path.indexOf("/../")) > 0) {
              final String pathSegment = path.substring(0, pathSegmentIndex);
              final int slashIndex = pathSegment.lastIndexOf('/');
  
              if (slashIndex < 0) {
                  continue;
              }
              if (!"..".equals(pathSegment.substring(slashIndex))) {
                  path =
                      path.substring(0, slashIndex + 1).concat(path.substring(pathSegmentIndex + 4));
              }
          }
          //      d) If the path ends with "<segment>/..", where <segment> is a
          //         complete path segment not equal to "..", that
          //         "<segment>/.." is removed.
          if (path.endsWith("/..")) {
              final String pathSegment = path.substring(0, path.length() - 3);
              final int slashIndex = pathSegment.lastIndexOf('/');
  
              if (slashIndex >= 0) {
                  path = path.substring(0, slashIndex + 1);
              }
          }
  
          path = removeLeadingSlashPoints(path);
  
          url.path = path;
          // Step 7: The resulting URL components, including any inherited from
          //         the base URL, are recombined to give the absolute form of
          //         the embedded URL.
          return url;
      }