code: public static String removeDotSegments(String path, boolean hasAuthority) {
          String rval = "";
  
          if (path.indexOf("/") == 0) {
              rval = "/";
          }
  
          // RFC 3986 5.2.4 (reworked)
          final List<String> input = new ArrayList<String>(Arrays.asList(path.split("/")));
          if (path.endsWith("/")) {
              // javascript .split includes a blank entry if the string ends with
              // the delimiter, java .split does not so we need to add it manually
              input.add("");
          }
          final List<String> output = new ArrayList<String>();
          for (int i = 0; i < input.size(); i++) {
              if (".".equals(input.get(i)) || ("".equals(input.get(i)) && input.size() - i > 1)) {
                  // input.remove(0);
                  continue;
              }
              if ("..".equals(input.get(i))) {
                  // input.remove(0);
                  if (hasAuthority
                          || (output.size() > 0 && !"..".equals(output.get(output.size() - 1)))) {
                      // [].pop() doesn't fail, to replicate this we need to check
                      // that there is something to remove
                      if (output.size() > 0) {
                          output.remove(output.size() - 1);
                      }
                  } else {
                      output.add("..");
                  }
                  continue;
              }
              output.add(input.get(i));
              // input.remove(0);
          }
  
          if (output.size() > 0) {
              rval += output.get(0);
              for (int i = 1; i < output.size(); i++) {
                  rval += "/" + output.get(i);
              }
          }
          return rval;
      }
docs: Removes dot segments from a JsonLdUrl path.
  
  @param path
  the path to remove dot segments from.
  @param hasAuthority
  true if the JsonLdUrl has an authority, false if not.
  @return The URL without the dot segments