Given two URLs, return a list of any mismatches.

    If the list is empty, the URLs are equivalent. Implemented by parsing and comparing
    the elements. See RFC 1738 for details.
199455
def find_url_mismatches(a_url, b_url):
    
    diff_list = []
    a_parts = urllib.parse.urlparse(a_url)
    b_parts = urllib.parse.urlparse(b_url)
    # scheme
    if a_parts.scheme.lower() != b_parts.scheme.lower():
        diff_list.append(
            'Schemes differ. a="{}" b="{}" differ'.format(
                a_parts.scheme.lower(), b_parts.scheme.lower()
            )
        )
    # netloc
    if a_parts.netloc.lower() != b_parts.netloc.lower():
        diff_list.append(
            'Network locations differ. a="{}" b="{}"'.format(
                a_parts.netloc.lower(), b_parts.netloc.lower
            )
        )
    # path
    if a_parts.path != b_parts.path:
        diff_list.append(
            'Paths differ: a="{}" b="{}"'.format(a_parts.path, b_parts.path)
        )
    # fragment
    if a_parts.fragment != b_parts.fragment:
        diff_list.append(
            'Fragments differ. a="{}" b="{}"'.format(a_parts.fragment, b_parts.fragment)
        )
    # param
    a_param_list = sorted(a_parts.params.split(";"))
    b_param_list = sorted(b_parts.params.split(";"))
    if a_param_list != b_param_list:
        diff_list.append(
            'Parameters differ. a="{}" b="{}"'.format(
                ', '.join(a_param_list), ', '.join(b_param_list)
            )
        )
    # query
    a_query_dict = urllib.parse.parse_qs(a_parts.query)
    b_query_dict = urllib.parse.parse_qs(b_parts.query)
    if len(list(a_query_dict.keys())) != len(list(b_query_dict.keys())):
        diff_list.append(
            'Number of query keys differs. a={} b={}'.format(
                len(list(a_query_dict.keys())), len(list(b_query_dict.keys()))
            )
        )
    for a_key in b_query_dict:
        if a_key not in list(b_query_dict.keys()):
            diff_list.append(
                'Query key in first missing in second. a_key="{}"'.format(a_key)
            )
        elif sorted(a_query_dict[a_key]) != sorted(b_query_dict[a_key]):
            diff_list.append(
                'Query values differ. key="{}" a_value="{}" b_value="{}"'.format(
                    a_key, sorted(a_query_dict[a_key]), sorted(b_query_dict[a_key])
                )
            )
    for b_key in b_query_dict:
        if b_key not in a_query_dict:
            diff_list.append(
                'Query key in second missing in first. b_key="{}"'.format(b_key)
            )
    return diff_list
841242
def urljoin(*urls):
    
    return reduce(_urljoin, [u.strip('/')+'/' for u in urls if u.strip('/')], '').rstrip('/')
1373217
function compareUrl(urlA, urlB) {
  var same = false;
  
  // Remove url fragments
  if( urlA.indexOf('#') > -1)
      urlA = urlA.split('#')[0];
 
  if( urlB.indexOf('#') > -1)
      urlB = urlB.split('#')[0];
  
  if(urlA != '' || urlB != ''){
      //Remove common subdomain
      urlA = urlA.toLowerCase().replace('www.','');
      urlB = urlB.toLowerCase().replace('www.','');
      
      // Make sure anything ends with / 
      if( endsWith(urlA,'/') == false)
          urlA = urlA + '/';
          
      if( endsWith(urlB,'/') == false)
          urlB = urlB + '/';    
          
      // Look for full match
      if(urlA.toLowerCase() == urlB.toLowerCase())
          same = true;
     
  }
  return same;
}
622120
function (url) {
	var result;

	LIST.some(function (state) {
		var params = state.pattern.match(url);

		if (params) {
			result       = state;
			state.params = params;
			return true;
		}
	});

	if (result) {
		var state        = result,
			parent_index = state.name.lastIndexOf('.'), parent_name;

		while (parent_index !== -1) {
			parent_name  = state.name.substring(0, parent_index);
			state.parent = STATES[parent_name];
			state        = state.parent;

			parent_index = state.name.lastIndexOf('.');
		}

		return result;
	}
}
727723
def matches?(*rules)
      rules.flatten!
      match   = self.local.matches?(rules)
      match ||= self.host.matches?(rules)
      return match if match

      # Does "root@*.com" match "root@example.com" domain name
      rules.each do |r|
        if r =~ /.+@.+/
          return r if File.fnmatch?(r, self.to_s)
        end
      end
      false
    end
830266
function matchRoutes(routes, path, query) {
  query = query === undefined ? {} : isString(query) ? qs.parse(query) : query;
  return matchRoutesImpl(routes, path, query);
}
747744
def join_url_parts(*args):
    
    # check for edge case
    if len(args) == 1:
        return args[0]

    return_val = clean_url_segment(args[0])

    for i in range(1, len(args)):
        arg = args[i]

        if i == len(args) - 1:
            # no need to remove a trailing slash if this is the last segment
            return_val += '/' + arg
        else:
            # remove a trailing slash so it won't be duplicated
            return_val += '/' + clean_url_segment(arg)

    return return_val
24240
def match_mac_list
      str = config_get('route_map', 'match_mac_list', @get_args)
      return if str.nil?
      str.empty? ? default_match_mac_list : str.split
    end
814189
def url_ok(match_tuple: MatchTuple) -> bool:
    """"""
    try:
        result = requests.get(match_tuple.link, timeout=5)
        return result.ok
    except (requests.ConnectionError, requests.Timeout):
        return False
664371
def basic_urisplit(uri):
    
    p = RFC3986_MATCHER(uri).groups()
    return (p[1], p[3], p[4], p[6], p[8])
973001
def etag_matches?(list, new_resource = request.post?)
      return !new_resource if list == '*'
      list.to_s.split(/\s*,\s*/).include? response['ETag']
    end
1103150
public static boolean containsURL(final URL[] urls, final URL url) {
        checkNotNull("urls", urls);
        checkNotNull("url", url);
        for (int i = 0; i < urls.length; i++) {
            final URL element = urls[i];
            final String elementStr = element.toExternalForm();
            final String urlStr = url.toExternalForm();
            if (elementStr.equals(urlStr)) {
                return true;
            }
        }
        return false;
    }
620612
private boolean _findMatches() throws IOException {
    // queue not empty
    if (!queueMatches.isEmpty()) {
      return true;
      // no more matches to be found
    } else if (currentPosition == NO_MORE_POSITIONS) {
      return false;
      // try to find matches
    } else {
      // subMatches: try to build matches while collecting
      Integer subMatchesStartPosition = null;
      Boolean subMatchesOptional = true;
      List<Match> subMatchesQueue = new ArrayList<>();
      // minimum startPosition previous, used to set lower boundary on
      // startPosition next
      Integer minStartPositionPrevious = null;
      // maximum endPosition previous, used to set upper boundary on
      // startPosition next
      Integer maxEndPositionPrevious = null;
      // other variables
      Integer minStartPositionNext = null;
      Integer minStartPosition = null;
      Integer minOptionalStartPosition = null;
      // adjusted minimum ignoreItem
      boolean adjustedMinimumIgnoreItem = false;
      // fill queue if necessary and possible
      for (int i = 0; i < queueSpans.size(); i++) {
        QueueItem item = queueSpans.get(i);
        // if span is optional, check docId
        if (!item.sequenceSpans.optional || (item.sequenceSpans.spans != null
            && item.sequenceSpans.spans.docID() == docId)) {
          // compute minimum startPosition until next non-optional item
          // used as lower boundary on endPosition next
          minStartPositionNext = null;
          for (int j = (i + 1); j < queueSpans.size(); j++) {

            // check for available lowestPosition
            if (!queueSpans.get(j).sequenceSpans.optional
                && queueSpans.get(j).lowestPosition != null) {
              minStartPositionNext = (minStartPositionNext == null)
                  ? queueSpans.get(j).lowestPosition
                  : Math.min(minStartPositionNext,
                      queueSpans.get(j).lowestPosition);
              // computing restrictions not possible
            } else {
              if (!queueSpans.get(j).sequenceSpans.optional) {
                minStartPositionNext = null;
              }
              break;
            }
          }
          // fill queue
          if ((minStartPositionPrevious == null) || subMatchesOptional) {
            fillQueue(item, null, maxEndPositionPrevious, minStartPositionNext);
          } else {
            fillQueue(item, minStartPositionPrevious, maxEndPositionPrevious,
                minStartPositionNext);
          }
          // try to adjust minimum ignoreItem
          if (!adjustedMinimumIgnoreItem && !item.sequenceSpans.optional
              && item.filledPosition) {
            if (minOptionalStartPosition != null) {
              ignoreItem.removeBefore(docId,
                  Math.min(minOptionalStartPosition, item.lowestPosition));
            } else {
              ignoreItem.removeBefore(docId, item.lowestPosition);
            }
            adjustedMinimumIgnoreItem = true;
          }
          // check for available positions
          if (!item.sequenceSpans.optional && item.noMorePositions
              && !item.filledPosition) {
            currentPosition = NO_MORE_POSITIONS;
            return false;
          }
          // build matches
          subMatchesQueue = _glue(subMatchesQueue, subMatchesOptional, item);
          // update subMatchesOptional
          if (!item.sequenceSpans.optional) {
            subMatchesOptional = false;
          }
          // check if matches are still achievable
          if (!subMatchesOptional && subMatchesQueue.isEmpty()) {
            // clean up previous queues
            if (subMatchesStartPosition != null) {
              int cleanStartPosition = subMatchesStartPosition;
              for (int j = 0; j <= i; j++) {
                queueSpans.get(j).del(cleanStartPosition);
                if (!queueSpans.get(j).sequenceSpans.optional) {
                  cleanStartPosition++;
                }
              }
            }
            return false;
          }
          // update subMatchesStartPosition
          if (subMatchesQueue.isEmpty()) {
            subMatchesStartPosition = null;
          } else {
            subMatchesStartPosition = subMatchesQueue.get(0).startPosition;
          }
          // compute minimum startPosition for next span
          if (item.lowestPosition != null) {
            minStartPositionPrevious = (minStartPositionPrevious == null)
                ? item.lowestPosition
                : Math.min(minStartPositionPrevious, item.lowestPosition);
          }
          // for optional spans
          if (item.sequenceSpans.optional) {
            // update stats
            if (item.lowestPosition != null) {
              minOptionalStartPosition = (minOptionalStartPosition == null)
                  ? item.lowestPosition
                  : Math.min(minOptionalStartPosition, item.lowestPosition);
            }
            // for not optional spans
          } else {
            // update stats, item.lowestPosition should be set
            minStartPosition = (minStartPosition == null) ? item.lowestPosition
                : Math.min(minStartPosition, item.lowestPosition);
            // reset maximum endPosition for next span
            maxEndPositionPrevious = null;
          }
          // compute maximum endPosition for next span
          if (item.lowestPosition != null) {
            for (Integer endPosition : item.queue.get(item.lowestPosition)) {
              maxEndPositionPrevious = (maxEndPositionPrevious == null)
                  ? endPosition : Math.max(maxEndPositionPrevious, endPosition);
            }
          }
        }
      }
      if (subMatchesQueue.isEmpty()) {
        // condition has only optional parts
        if (subMatchesOptional) {
          // check for
          boolean allFinished = true;
          for (int i = 0; i < queueSpans.size(); i++) {
            if (!queueSpans.get(i).noMorePositions) {
              allFinished = false;
              break;
            }
          }
          if (allFinished) {
            currentPosition = NO_MORE_POSITIONS;
          }
        }
        return false;
      } else if ((minOptionalStartPosition != null)
          && (minOptionalStartPosition < subMatchesStartPosition)) {
        for (int i = 0; i < queueSpans.size(); i++) {
          if (!queueSpans.get(i).sequenceSpans.optional) {
            break;
          } else {
            queueSpans.get(i).del(minOptionalStartPosition);
          }
        }
        return false;
      } else {
        for (int i = 0; i < queueSpans.size(); i++) {
          queueSpans.get(i).del(subMatchesStartPosition);
        }
        for (Match m : subMatchesQueue) {
          if (!queueMatches.contains(m)) {
            queueMatches.add(m);
          }
        }
        ignoreItem.removeBefore(docId, queueMatches.get(0).startPosition);
        return true;
      }
    }
  }
1266739
def index_lists_equal(a: List[Index], b: List[Index]) -> bool:
    
    n = len(a)
    if len(b) != n:
        return False
    for i in range(n):
        if not indexes_equal(a[i], b[i]):
            log.debug("Mismatch: {!r} != {!r}", a[i], b[i])
            return False
    return True
339779
def match_url(self, request):
        
        matched = False
        if self.exact_url:
            if re.match("%s$" % (self.url,), request.path):
                matched = True
        elif re.match("%s" % self.url, request.path):
            matched = True
        return matched
74090
def is_duplicate_content_url(url1, url2):
    """"""
    if url1 == url2:
        return True
    if url2 in url1:
        url1 = shorten_duplicate_content_url(url1)
        if not url2.endswith('/') and url1.endswith('/'):
            url2 += '/'
        return url1 == url2
    if url1 in url2:
        url2 = shorten_duplicate_content_url(url2)
        if not url1.endswith('/') and url2.endswith('/'):
            url1 += '/'
        return url1 == url2
    return False
473248
def match_route(self, reqpath):
        ''''''
        route_dicts = [routes for _, routes in self.api.http.routes.items()][0]
        routes = [route for route, _ in route_dicts.items()]
        #no prameters in path
        if reqpath in routes:
            return reqpath
        for route in routes:
            #replace params in route with regex
            if re.match(re.sub(r'/{[^{}]+}', '/\w+', route) + '$', reqpath):
                return route
        return reqpath