public static List<String> tokenizeUrlPath(String urlPath) throws InvalidUrlException {
    if (StringUtils.isBlank(urlPath)) {
      return Collections.emptyList();
    }

    if (!urlPath.startsWith("/")) {
      throw new InvalidUrlException("UrlParser tokenize error, invalid urls: " + urlPath);
    }

    String[] dirs = urlPath.split("/");
    List<String> dirlist = new ArrayList<String>();
    for (int i = 0; i < dirs.length; ++i) {
      if ((dirs[i].contains(".") || dirs[i].contains("?") || dirs[i].contains("*"))
          && (!dirs[i].startsWith("{") || !dirs[i].endsWith("}"))) {
        throw new InvalidUrlException("UrlParser tokenize error, invalid urls: " + urlPath);
      }

      if (!StringUtils.isEmpty(dirs[i])) {
        dirlist.add(dirs[i]);
      }
    }
    return dirlist;
  }
Split url path into segments. support the path with url template variable.

@param urlPath the url path
@return a list of path directories
@throws InvalidUrlException if the url is invalid
src/main/java/com/eudemon/ratelimiter/utils/UrlUtils.java