Matches the current request against mapped routes
438435
public function matchCurrentRequest()
    {
        $requestMethod = (
            isset($_POST['_method'])
            && ($_method = strtoupper($_POST['_method']))
            && in_array($_method, array(RequestMethodInterface::METHOD_PUT, RequestMethodInterface::METHOD_DELETE), true)
        ) ? $_method : $_SERVER['REQUEST_METHOD'];

        $requestUrl = $_SERVER['REQUEST_URI'];

        // strip GET variables from URL
        if (($pos = strpos($requestUrl, '?')) !== false) {
            $requestUrl = substr($requestUrl, 0, $pos);
        }

        return $this->match($requestUrl, $requestMethod);
    }
606532
public function getCurrentRouteMatch() {
    if (empty($this->currentRouteMatch)) {
      $this->currentRouteMatch = \Drupal::service('current_route_match');
    }
    return $this->currentRouteMatch;
  }
523374
def match_url(self, path, method='GET'):
        
        path = path.strip().lstrip('/')
        handler, param = self.routes.match(method + ';' + path)
        if handler: return handler, param
        if method == 'HEAD':
            handler, param = self.routes.match('GET;' + path)
            if handler: return handler, param
        handler, param = self.routes.match('ANY;' + path)
        if handler: return handler, param
        return None, {}
817770
protected function matchRoute()/*# : bool */
    {
        foreach ($this->getCollectors() as $coll) {
            if ($coll->matchRoute($this->result)) {
                return true;
            }
        }
        return false;
    }
628362
public function matchRequest($requestedRoute, $httpMethod)
    {
        // Iterate through each route that has been registered
        foreach ($this->routes as $route => $callback) {
            
            // Convert the route to a regex pattern
            $routeRx = preg_replace(
                        '%/:([^ /?]+)(\?)?%',
                        '/\2(?P<\1>[^ /?]+)\2',
                    $route);
            
            // If the route also defined a HTTP method to match against, 
            // append the requested route with the request's method
            $routeMethod = strstr($route, ':', true);
            if ($routeMethod && substr($routeMethod, -1) != '/') {
                $requestPrepend = strtolower($httpMethod).':';
            } else {
                $requestPrepend = '';
            }
            
            // Check for a regex match with the requested route. Store the 
            // matches in a variable so the Request instance can be informed.
            if (preg_match('%^' . $routeRx . '$%',
                            $requestPrepend.$requestedRoute,
                            $uriParams)
                ) {
                // A route match was found
                
                // Before returning true, store the params 
                // that were matched, and store the matched route.
                foreach ($uriParams as $key => $value) {
                    if (is_numeric($key)) unset($uriParams[$key]);
                }
                $this->params = (object) $uriParams;
                $this->matched = $route;
                
                return true;
            }
        }
        
        // No matches caught
        return false;
    }
224353
def match(self, request, service):
		
		uri = self.normalize_uri(request.path())

		if request.session().protocol() not in self.protocols:
			return

		if request.method() not in self.methods:
			return

		if self.virtual_hosts and request.virtual_host() not in self.virtual_hosts:
			return

		if self.ports and int(request.session().server_address().port()) not in self.ports:
			return

		match_obj = self.re_pattern.match(uri)

		if not match_obj:
			return

		presenter_action = self.action
		presenter_args = self.presenter_args.copy()

		for i in range(len(self.route_args)):
			if self.route_args[i] == 'action':
				presenter_action = match_obj.group(i + 1)
			else:
				presenter_args[self.route_args[i]] = match_obj.group(i + 1)

		return WWebTargetRoute(self.presenter, presenter_action, self, service.route_map(), **presenter_args)
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
1363834
private Route matchRestful(String uri, ControllerPath controllerPathObject, HttpMethod method, AppController controller) {

        String theUri = uri.endsWith("/") ? uri.substring(0, uri.length() - 1) : uri;
        String controllerPath = (controllerPathObject.getControllerPackage() != null ? "/" + controllerPathObject.getControllerPackage().replace(".", "/") : "") + "/" + controllerPathObject.getControllerName();
        String tail = theUri.length() > controllerPath.length() ? theUri.substring(controllerPath.length() + 1) : "";
        String[] parts = split(tail, "/");

        //GET 	/photos 	            index 	display a list of all photos
        if (controllerPath.equals(theUri) && method.equals(HttpMethod.GET)) {
            return new Route(controller, "index", method);
        }

        //GET 	/photos/new_form 	    new_form        return an HTML form for creating a new photo
        if (parts.length == 1 && method.equals(HttpMethod.GET) && parts[0].equalsIgnoreCase("new_form")) {
            return new Route(controller, "new_form", method);
        }

        //POST 	/photos 	            create 	        create a new photo
        if (parts.length == 0 && method.equals(HttpMethod.POST)) {
            return new Route(controller, "create", method);
        }

        //GET 	/photos/id 	        show            display a specific photo
        if (parts.length == 1 && method.equals(HttpMethod.GET)) {
            return new Route(controller, "show", parts[0], method);
        }

        //GET 	/photos/id/edit_form   edit_form 	    return an HTML form for editing a photo
        if (parts.length == 2 && method.equals(HttpMethod.GET) && parts[1].equalsIgnoreCase("edit_form")) {
            return new Route(controller, "edit_form", parts[0], method);
        }

        //PUT 	/photos/id 	        update          update a specific photo
        if (parts.length == 1 && method.equals(HttpMethod.PUT)) {
            return new Route(controller, "update", parts[0], method);
        }

        //DELETE 	/photos/id 	        destroy         delete a specific photo
        if (parts.length == 1 && method.equals(HttpMethod.DELETE)) {
            return new Route(controller, "destroy", parts[0], method);
        }

        //OPTIONS 	/photos/            options
        if (parts.length == 0 && method.equals(HttpMethod.OPTIONS)) {
            return new Route(controller, "options", method);
        }

        //OPTIONS 	/photos/new_form 	    new_form        return an HTML form for creating a new photo
        if (parts.length == 1 && method.equals(HttpMethod.OPTIONS) && parts[0].equalsIgnoreCase("new_form")) {
            Route r = new Route(controller, "options", parts[0], method);
            r.setTargetAction("new_form");
            return r;

        }

        //OPTIONS 	/photos/id/edit_form 	    edit_form
        if (parts.length == 2 && method.equals(HttpMethod.OPTIONS) && parts[1].equalsIgnoreCase("edit_form")) {
            Route r = new Route(controller, "options", parts[0], method);
            r.setTargetAction("edit_form");
            return r;
        }

        //OPTIONS /photos/id 	        show            display a specific photo
        if (parts.length == 1 && method.equals(HttpMethod.OPTIONS)) {
            Route r = new Route(controller, "options", parts[0], method);
            r.setTargetAction("show");
            return r;
        }

        LOGGER.warn("Failed to find action for request: " + uri);
        return null;
    }
444807
public final function match(ServerRequestInterface &$request): RouteInterface
   {
       foreach ($this->route as $value) {
           if ($this->matcher->match($request, $value)) {
               return $value;
           }
       }
       throw new RouterException(
           "Can't match "
         . $request->getMethod() . " "
         . $request->getUri()->getPath());
   }
1035895
def _match_view(self, method, route_params):
        
        method = method.upper()
        route_params = frozenset(k for k, v in route_params.items() if v is not None)

        for view_name, info in self.methods_map[method].items():
            if info.matches(method, route_params):
                return getattr(self, view_name)
        else:
            return None
157154
public function match( Request $request )
	{
		$routes = $this->get( $request->getMethod() );

		// First, we will see if we can find a matching route for this current request
		// method. If we can, great, we can just return it so that it can be called
		// by the consumer. Otherwise we will check for routes with another verb.
		$route = $this->check( $routes, $request );

		if ( !is_null( $route ) )
		{
			return $route->bind( $request );
		}

		// If no route was found we will now check if a matching route is specified by
		// another HTTP verb. If it is we will need to throw a MethodNotAllowed and
		// inform the user agent of which HTTP verb it should use for this route.
		$others = $this->checkForAlternateVerbs( $request );

		if ( count( $others ) > 0 )
		{
			return $this->getRouteForMethods( $request, $others );
		}

		throw new NotFoundHttpException;
	}
830266
function matchRoutes(routes, path, query) {
  query = query === undefined ? {} : isString(query) ? qs.parse(query) : query;
  return matchRoutesImpl(routes, path, query);
}
1116210
def get_match(self, match_id):
        """"""
        return self._make_req(endpoints.MATCH, dict(
            k=self.key,
            mp=match_id), Match)
461169
public function matchRequest(Request $request)
    {
        try {
            $parameters = parent::matchRequest($request);
            $this->matchedRouteRequest = $request;
            return $parameters;
        } catch (\Exception $e) {
            throw $e;
        }


    }
1150296
function match(RequestInterface $request)
    {
        $method = $request->getMethod();

        if (strtoupper($method) !== strtoupper($this->getMethod()))
            return false;

        $routeMatch = clone $this;
        return $routeMatch;
    }
1065021
protected function matchRoute(ServerRequestInterface $request): ?RouteInterface
    {
        foreach ($this->routes as $route) {
            // Matched route will return new route instance with matched parameters
            $matched = $route->match($request);

            if (!empty($matched)) {
                return $matched;
            }
        }

        if (!empty($this->default)) {
            return $this->default->match($request);
        }

        // unable to match any route
        return null;
    }
1123365
def routing(routes, request):
    """"""

    # strip trailing slashes from request path
    path = request.path.strip('/')

    # iterate through routes to match
    args = {}
    for name, route in routes.items():
        if route['path'] == '^':
            # this section exists because regex doesn't work for null character as desired
            if path == '':
                match = [True]
            else:
                match = []
        else:
            match = re.findall(route['path'], path)
        
        if match:
            # found the matching url, iterate through variables to pass data
            # check if method exists
            if not request.method in route['method']:
                raise TornMethodNotAllowed
            
            values = match[0] # in form of tuples
            if type(values) != bool:
                for i in range(len(route['variables'])):
                    # if value is blank, check if default exists and pass it instead
                    if type(values) == str:
                        args[route['variables'][i]] = values
                    else:
                        if not values[i] and route['variables'][i] in route['defaults']:
                            values[i] = route['defaults'][route['variables'][i]]
                        args[route['variables'][i]] = values[i]
            
            # we have the variables we need, args, path, controller
            return {
                'kwargs'        : args,
                'controller'    : route['controller']
            }
    raise TornNotFoundError