code: public static String repositoryUrl( HttpServletRequest request ) {
          String requestURL = request.getRequestURL().toString();
          int delimiterSegmentIdx = requestURL.length();
          for (String methodName : ALL_METHODS) {
              if (requestURL.indexOf(methodName) != -1) {
                  delimiterSegmentIdx = requestURL.indexOf(methodName);
                  break;
              }
          }
          return requestURL.substring(0, delimiterSegmentIdx);
      }
docs: Determines the absolute URL to a repository/workspace from the given request, by trimming known service methods.
  
  @param request a {@code non-null} {@link HttpServletRequest}
  @return a string representing an absolute-url