static urlMatchesPattern(url, pattern = '/') {
    const urlObj = new URL(url);
    const urlPath = urlObj.pathname + urlObj.search;

    const hasWildcard = pattern.includes('*');
    const hasDollarSign = pattern.includes('$');

    /**
     * There are 4 different cases of path strings.
     * Paths should have already been validated with #validatePath.
     *
     * Case #1: No special characters
     * Example: "/cat"
     * Behavior: URL should start with given pattern.
     */
    if (!hasWildcard && !hasDollarSign) {
      return urlPath.startsWith(pattern);
      /**
       * Case #2: $ only
       * Example: "/js$"
       * Behavior: URL should be identical to pattern.
       */
    } else if (!hasWildcard && hasDollarSign) {
      return urlPath === pattern.slice(0, -1);
      /**
       * Case #3: * only
       * Example: "/vendor*chunk"
       * Behavior: URL should start with the string pattern that comes before the wildcard
       * & later in the string contain the string pattern that comes after the wildcard.
       */
    } else if (hasWildcard && !hasDollarSign) {
      const [beforeWildcard, afterWildcard] = pattern.split('*');
      const remainingUrl = urlPath.slice(beforeWildcard.length);
      return urlPath.startsWith(beforeWildcard) && remainingUrl.includes(afterWildcard);
      /**
       * Case #4: $ and *
       * Example: "/vendor*chunk.js$"
       * Behavior: URL should start with the string pattern that comes before the wildcard
       * & later in the string end with the string pattern that comes after the wildcard.
       */
    } else if (hasWildcard && hasDollarSign) {
      const [beforeWildcard, afterWildcard] = pattern.split('*');
      const urlEnd = urlPath.slice(beforeWildcard.length);
      return urlPath.startsWith(beforeWildcard) && urlEnd.endsWith(afterWildcard.slice(0, -1));
    }
    return false;
  }
Determines whether a URL matches against a robots.txt-style "path".
Pattern should use the robots.txt format. E.g. "/*-article.html" or "/". Reference:
https://developers.google.com/search/reference/robots_txt#url-matching-based-on-path-values
@param {string} url
@param {string=} pattern
@return {boolean}