code: protected boolean urlPatternMatch(String pattern1, String pattern2) {
          if (pattern1.equals(pattern2)) {
              return true;
          }
          if (pattern1.equals("/*")) {
              return true;
          }
          if (pattern1.startsWith("/") && pattern1.endsWith("/*")) {
              String subPattern = pattern1.substring(0, pattern1.length() - 2);
              int pLength = subPattern.length();
              if (pattern2.startsWith(subPattern)) {
                  if (pattern2.length() == pLength || pattern2.charAt(pLength) == '/') {
                      return true;
                  }
              }
          }
  
          if (pattern1.startsWith("*.")) {
              if (pattern2.endsWith(pattern1.substring(1))) {
                  return true;
              }
          }
  
          if (pattern1.equals("/")) {
              return true;
          }
          return false;
      }
docs: ***********************************************************************
  The pattern match rules are as follows.
  1) their pattern values are String equivalent, or
  2) this pattern is the path-prefix pattern "/*", or
  3) this pattern is a path-prefix pattern (that is, it starts with
  "/" and ends with "/*") and the other pattern starts with the
  substring of this pattern, minus its last 2 characters, and the
  next character of the other pattern, if there is one, is "/", or
  4) this pattern is an extension pattern (that is, it starts with "*.")
  and the other pattern ends with this pattern, or
  5) this pattern is the special default pattern, "/", which matches all
  other patterns.
  ************************************************************************