a simple route used in situations when main routing method fails (exceed max number of loop iterations, inaccessible)
965952
function(from, to, opt) {

            // Find a route which breaks by 45 degrees ignoring all obstacles.

            var theta = from.theta(to);

            var route = [];

            var a = { x: to.x, y: from.y };
            var b = { x: from.x, y: to.y };

            if (theta % 180 > 90) {
                var t = a;
                a = b;
                b = t;
            }

            var p1 = (theta % 90) < 45 ? a : b;
            var l1 = new g.Line(from, p1);

            var alpha = 90 * Math.ceil(theta / 90);

            var p2 = g.Point.fromPolar(l1.squaredLength(), g.toRad(alpha + 135), p1);
            var l2 = new g.Line(to, p2);

            var intersectionPoint = l1.intersection(l2);
            var point = intersectionPoint ? intersectionPoint : to;

            var directionFrom = intersectionPoint ? point : from;

            var quadrant = 360 / opt.directions.length;
            var angleTheta = directionFrom.theta(to);
            var normalizedAngle = g.normalizeAngle(angleTheta + (quadrant / 2));
            var directionAngle = quadrant * Math.floor(normalizedAngle / quadrant);

            opt.previousDirectionAngle = directionAngle;

            if (point) route.push(point.round());
            route.push(to);

            return route;
        }
683426
function() {
      // Used for de-duping
      var paths = {};

      // Each controller has a `routes` object
      // Connect all routes defined in controllers
      _.forEach(router.controllers, function(controller) {
        _.forEach(controller.routes, function(route, method) {
          _.forEach(route, function(routeOptions, path) {
            // If path/method has already been defined, skip
            if (paths[path] === method) {
              debug.warn('Skipping duplicate route: [%s] %s', method, path);
              return;
            }

            // If no route action is defined, skip
            if (!routeOptions.action) {
              debug.warn('No action defined for route: [%s] %s', method, path);
              return;
            }

            // Setup controller scoped middleware
            // These apply to all routes in the controller
            var pre = _.invokeMap(controller.pre, 'bind', controller) || [];
            var before = _.invokeMap(controller.before, 'bind', controller) || [];
            var after = _.invokeMap(controller.after, 'bind', controller) || [];

            // Setup route scoped middleware
            // These apply only to this route
            var middleware = routeOptions.middleware || [];

            // Build the route handler (callback)
            var handler = router._buildHandler(controller, routeOptions);

            // Connect the route
            router[method](path, pre, middleware, before, handler, after);

            // Add route to set of connected routes
            router.routes.push({
              url: router.url,
              method: method,
              path: path
            });

            // Use for de-duping
            paths[path] = method;
          });
        });
      });

      // Debug logging
      _.forEach(router.routes, function(route) {
        debug.info('Route [%s] %s', route.method, route.url + route.path);
      });
    }
923224
private function buildErrorRoute(): void
    {
        //check if there is a declared route for errors, if no exit with false
        if (($key = \array_search($this->badRoute, \array_column($this->routes->getArrayCopy(), 'name'), true)) === false) {
            $this->route = new NullRoute();

            return;
        }

        //build and store route for errors
        $this->route = $this->routes[$key];
    }
226190
function(req) {
        var args = utils.arg2arr(arguments), index = -1;
        var allHandlers = this._handlers.concat(this._lastHandlers);
        var next = function(error) {
            var item = allHandlers[++index];
            if (item) {
                var matched = false;
                if (utils.isString(item.routeExp)) {
                    matched = req.url.indexOf(item.routeExp) === 0;
                } else if (utils.type(item.routeExp) === 'regexp') {
                    matched = item.routeExp.test(parse(req.url).pathname);
                }
                //
                if (matched) {
                    var clone = args.concat();
                    if (error) { clone.push(error); }
                    item.handler.apply(null, clone);
                }
            }
        };
        args.push(next);
        next();
    }
388422
function(request, params, route) {
        var uRe         = params.url.split(/\//)
            , uRo       = route.split(/\//)
            , maxLen    = uRo.length
            , score     = 0
            , r         = {}
            , i         = 0;

        //attaching routing description for this request
        request.routing = params; // can be retried in controller with: req.routing

        if (uRe.length === uRo.length) {
            for (; i<maxLen; ++i) {
                if (uRe[i] === uRo[i]) {
                    ++score
                } else if (score == i && hasParams(uRo[i]) && fitsWithRequirements(request, uRo[i], uRe[i], params)) {
                    ++score
                }
            }
        }

        r.past = (score === maxLen) ? true : false;
        r.request = request;

        return r
    }
889412
async function main() {
  event.$emit('before-client-render')

  if (globalState.initialData) {
    dataStore.replaceState(globalState.initialData)
  }

  await routerReady(router)

  if (router.getMatchedComponents().length === 0) {
    throw new ReamError(pageNotFound(router.currentRoute.path))
  }
}
50801
def _error_msg_routes(iface, option, expected):
    '''
    
    '''
    msg = 'Invalid option -- Route interface: {0}, Option: {1}, Expected: [{2}]'
    return msg.format(iface, option, expected)
314458
def _raise_error_routes(iface, option, expected):
    '''
    
    '''
    msg = _error_msg_routes(iface, option, expected)
    log.error(msg)
    raise AttributeError(msg)
1364111
private Route matchStandard(HttpMethod httpMethod, String requestUri, ActionInvoker invoker) throws ClassLoadException {
        // find potential routes
        for (InternalRoute internalRoute : internalRoutes) {
            if (internalRoute.matches(requestUri) ) {
                Route deferred = deduceRoute(internalRoute, httpMethod, requestUri, invoker);
                if (deferred != null) return deferred;
            }
        }
        throw new ClassLoadException("A route for request " + requestUri + " could not be deduced");
    }
149713
def navigate(self, name, *args):
        
        if name not in self.routes:
            raise Exception('invalid route name \'%s\'' % name)
        elif callable(self.routes[name]):
            return self.routes[name](self, *args)
        raise Exception('route %s not callable', name)
806662
function route_(element, newURL, alreadyShown) {
    let lastMatch = null;
    let newHash = newURL.split('#')[1] || '';
    let lastHash = newHash.split('/').reverse()[0];
    let match = lastHash.match(
      new RegExp(element.getAttribute('hash')));
    let parents = [element];

    // if match...
    if (match && match[0] === lastHash &&
      (match.length === 1 ||
      !document.querySelector(`[hash="${lastHash}"]`))) {

      // match_ newHash pushing all matched elements to parents
      lastMatch = match_(newHash, parents, []);

      // if default route do not match
      if ((lastMatch !== newHash) && (element.getAttribute('hash') === '')) {
        lastMatch = null;
      } else {
        match = newHash.match(new RegExp(parents.reduce((acc, curr) => {
          curr && (acc = curr.getAttribute('hash') + (acc ? '/' : '') + acc);
          return acc;
        }, '')));
        (!match) && (lastMatch = null);

        // unhide all matched elements
        match && parents.forEach(element => element && unhide_(element));

        // hide_ last elements. I mean, if go
        // from /page1/page2/page3
        // to   /page1/page2/page5
        // then hide only page3
        match &&
          (alreadyShown instanceof Array) &&
          alreadyShown.reduce((acc, curr) => {
            curr && !parents.includes(curr) && acc.push(curr);
            return acc;
          }, []).reverse().forEach(item => hide_(item));

        // if match, and no stateRevert then update lastMatch and dispatch show
        match && !stateRevert && (lastMatch = parents) &&
          dispatchShow_(element, match.slice(1)
          .reduce((detail, hash, i) => {
            detail[`param${i + 1}`] = hash;
            return detail;
          }, { router: element }));
      }
    } else {
      // do not hide elements unnecessarily
      if (!(alreadyShown.find &&
          alreadyShown.find(show => show === element))) {
        hide_(element);
      }
    }
    return lastMatch;
  }
579770
function asyncWrap (route) {
  return (req, res, next) => route(req, res, next).catch(next)
}
1096202
function routeFromRel (route, rel) {
    // if rel is empty string then this is route
    if (rel.length === 0) {
        // set root flag on route
        route.root = true
        // return route
        return route
    }
    // if rel is above root this is error
    assert.ok(!rel.match(/^\./), 'relative path above app root: '+rel)
    // split rel into directories
    var dirs = rel.split('/')
    // get next route node for each dir in rel path
    _.each(dirs, dir => {
        // create sub node if it does not exists
        if (!route.routes) {
            route.routes = {}
        }
        // create new entry for dir if it does not exist
        if (!route.routes[dir]) {
            route.routes[dir] = {}
        }
        // switch context
        route = route.routes[dir]
    })
    // return resolved route
    return route
}
817143
def _route(self, args, request=None):
        '''
        
        '''
        if request is None:
            from pecan import request
        # convention uses "_method" to handle browser-unsupported methods
        method = request.params.get('_method', request.method).lower()

        # make sure DELETE/PUT requests don't use GET
        if request.method == 'GET' and method in ('delete', 'put'):
            abort(405)

        # check for nested controllers
        result = self._find_sub_controllers(args, request)
        if result:
            return result

        # handle the request
        handler = getattr(
            self,
            '_handle_%s' % method,
            self._handle_unknown_method
        )

        try:
            if len(getargspec(handler).args) == 3:
                result = handler(method, args)
            else:
                result = handler(method, args, request)

            #
            # If the signature of the handler does not match the number
            # of remaining positional arguments, attempt to handle
            # a _lookup method (if it exists)
            #
            argspec = self._get_args_for_controller(result[0])
            num_args = len(argspec)
            if num_args < len(args):
                _lookup_result = self._handle_lookup(args, request)
                if _lookup_result:
                    return _lookup_result
        except (exc.HTTPClientError, exc.HTTPNotFound,
                exc.HTTPMethodNotAllowed) as e:
            #
            # If the matching handler results in a 400, 404, or 405, attempt to
            # handle a _lookup method (if it exists)
            #
            _lookup_result = self._handle_lookup(args, request)
            if _lookup_result:
                return _lookup_result

            # Build a correct Allow: header
            if isinstance(e, exc.HTTPMethodNotAllowed):

                def method_iter():
                    for func in ('get', 'get_one', 'get_all', 'new', 'edit',
                                 'get_delete'):
                        if self._find_controller(func):
                            yield 'GET'
                            break
                    for method in ('HEAD', 'POST', 'PUT', 'DELETE', 'TRACE',
                                   'PATCH'):
                        func = method.lower()
                        if self._find_controller(func):
                            yield method

                e.allow = sorted(method_iter())

            raise

        # return the result
        return result
1278158
function getRedirectRoute(that, path, newRoutePath, newRoutes, routeDivergenceIndex) {
        if(newRoutes.length > 0) {
            var redirectInfo = newRoutes[newRoutes.length-1].route.redirectInfo
        } else {
            var redirectInfo = newRoutePath[routeDivergenceIndex-1].route.redirectInfo
        }

        if(redirectInfo !== undefined) {
            var newPathToEmit = redirectInfo.path
            if(redirectInfo.emitOldPath)
                newPathToEmit = path

            try {
                var newPath = getPathFromInput(that.transform, redirectInfo.path)
            } catch(e) {
                if(e.message === 'pathNotArray') {
                    throw new Error("A route passed to `redirect` must be an array")
                } else {
                    throw e
                }
            }

            return getNewRouteInfo(that, newRoutePath, newPath, newPathToEmit)
        }

        return false
    }
759240
function preBottom(ctx, goToBottomMiddleware) {
      // If no route match or no methods are defined, go to next middleware
      if (node.isGag || !node.methods.size) {
        return next()
      }
      // If there is no one middleware
      // it's a 405 error
      if (!bottom.length) {
        ctx.response.set('Allow', this.methods.toString())
        ctx.response.status = 405
        return
      }

      return goToBottomMiddleware()
    }
295168
function ensure_valid_routes(raw_routes) {
    !Array.isArray(raw_routes)
        ? throw_type_error('routes must be an array')
        : 0 === raw_routes.length
            && throw_error('There are no routes defined')
        ; // eslint-disable-line indent
    const routes = [];
    for (let i = 0, n = raw_routes.length - 1; i <= n; i++) {
        const raw_route = raw_routes[i];
        raw_route.path
            ? raw_route.pattern || raw_route.pattern_tokens
                ? throw_error(
                    'If route.path is defined,',
                    'route.pattern and route.pattern_tokens are invalid',
                    ) // eslint-disable-line indent
                : 'string' !== typeof raw_route.path
                    && throw_type_error('route.path must be a string')
            : raw_route.pattern
                ? !(raw_route.pattern instanceof RegExp)
                    && throw_type_error(
                        'route.pattern must be a regular expression',
                        ) // eslint-disable-line indent
                : throw_type_error(
                    'route.path must be a string',
                    'or route.pattern must be regular expression',
                    ) // eslint-disable-line indent
            ; // eslint-disable-line indent
        raw_route.redirect_to
            ? 'string' !== typeof raw_route.redirect_to
                ? throw_type_error('route.redirect_to must be a string')
                : raw_route.component
                    && throw_error(
                        'If route.redirect_to is defined,',
                        'route.component is invalid',
                        ) // eslint-disable-line indent
            : !(raw_route.component.prototype instanceof REACT.Component)
                && throw_type_error('route.component must be a React Component')
            ; // eslint-disable-line indent
        routes.push({
            path: raw_route.path ? ensure_valid_path(raw_route.path) : null,
            pattern: raw_route.pattern || null,
            pattern_tokens:
                ensure_valid_pattern_tokens(raw_route.pattern_tokens)
                , // eslint-disable-line
            redirect_to: raw_route.redirect_to || null,
            component: raw_route.component,
            }); // eslint-disable-line indent
    }
    return routes;
}