new syntax for mapping routes
2308
public static function map(
		string $url = null, string $destination, string $route_name = null, string $method = null
	) :Route {
		// We cannot allow duplicate route names for reversing reasons
		if($route_name && self::hasRoute($route_name)) {
			// throw an exception
			throw new Exception("Router::map() The route {$route_name} has already been declared");
		}
		// create a new route
		$route = new Route($route_name);
		// configure the route
		$route
			->setUrl($url)
			->setDestination($destination)
			->setMethod($method);
		// add it to the list of known routes
		self::$_routes[$route->name] = $route;
		// return the route for finer tuning
		return self::$_routes[$route->name];
	}
381563
function (data, routes) {
		var tempRoutes = {};

		data.forEach(function (r) {
			if (r && r.routes) {
				for (var key in r.routes) {
					if (key && r.routes[key] && !routes[r.rootApiPath + '/' + key])
						routes[r.rootApiPath + '/' + key] = r.routes[key]
				}
			}
		});
	}
237071
function defineRoute (server, opts) {

    server.route({
        method: 'GET',
        path: '/' + opts.plural,
        handler: handler,
        config: {
            jsonp: 'callback',
            validate: {
                query: {},
                payload: false
            }
        }
    });

    function handler (req) {
        var res = {};
        res[opts.plural] = opts.things;
        req.reply(res);
    }

}
428462
function(route, args, base) {
            base = base || "";
            args = args || {};
            var url = route;
            url = url.replace("#!/","#").replace("#!", "#").replace("#", "");
            _.map(args, function(value, attr) {
                url = url.replace("\:"+attr, value);
            });
            return base+"#/"+url;
        }
899345
function _normalizeUrl (route, prefix) {
  const _route = Object.assign({}, route)
  const url = _route.url
                 .replace(/^\//, '')
                 .replace(/\/$/, '')

  // build prefix
  prefix = prefix ? `/${prefix}` : ''
  _route.url = url ? `${prefix}/${url}/` : `${prefix}/`

  debug(`rewritting url: ${_route.url}`)

  return _route
}
1241040
function _mapInDNs(&$root, $path, $asn1)
    {
        $dns = &$this->_subArray($root, $path);

        if (is_array($dns)) {
            for ($i = 0; $i < count($dns); $i++) {
                for ($j = 0; $j < count($dns[$i]); $j++) {
                    $type = $dns[$i][$j]['type'];
                    $value = &$dns[$i][$j]['value'];
                    if (is_object($value) && $value instanceof Element) {
                        $map = $this->_getMapping($type);
                        if (!is_bool($map)) {
                            $decoded = $asn1->decodeBER($value);
                            $value = $asn1->asn1map($decoded[0], $map);
                        }
                    }
                }
            }
        }
    }
1267533
function defineRoute (server, opts) {

    server.route({
        method: 'GET',
        path: '/',
        handler: handler,
        config: {
            jsonp: 'callback',
            validate: {
                query: {},
                payload: false
            }
        }
    });

    function handler (req) {
        var host = req.info.host;
        req.reply({
            endpoints: [
                {
                    method: 'GET',
                    endpoint: '/' + opts.plural,
                    description: 'Get all ' + opts.plural,
                    example: 'http://' + host + '/' + opts.plural
                },
                {
                    method: 'GET',
                    endpoint: '/random',
                    description: 'Get a random ' + opts.singular,
                    example: 'http://' + host + '/random'
                },
                {
                    method: 'GET',
                    endpoint: '/bomb?count={n}',
                    description: 'Get multiple random ' + opts.plural,
                    example: 'http://' + host + '/bomb?count=3'
                },
                {
                    method: 'GET',
                    endpoint: '/count',
                    description: 'Get the number of available ' + opts.plural,
                    example: 'http://' + host + '/count'
                }
            ]   
        });
    }

}
1277066
def _routes(self, app):
        
        _routes = []
        prefix = self.url_prefix if self.url_prefix is not None else ""
        for rule in app.url_map.iter_rules():
            if str(rule).startswith(prefix):
                _routes.append({
                    'path':rule.rule,
                    'name':rule.endpoint,
                    'methods':list(rule.methods)
                })
        returns = {
            'api': self.name,
            'url_root': request.url_root,
            'routes': _routes
        }
        return jsonify(returns)
756524
def p_route(self, p):
        """"""
        p[0] = AstRouteDef(self.path, p.lineno(1), p.lexpos(1), p[2], p[3], p[5], *p[4])
        if len(p) > 7:
            p[0].set_doc(p[8])
            if p[9]:
                keys = set()
                for attr in p[9]:
                    if attr.name in keys:
                        msg = "Attribute '%s' defined more than once." % attr.name
                        self.errors.append((msg, attr.lineno, attr.path))
                    keys.add(attr.name)
                p[0].set_attrs(p[9])
371079
public function map() : void
    {
        $this->router->pattern('id', '\d+');
        $this->router->pattern('hash', '[a-z0-9]+');
        $this->router->pattern('uuid', '[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}');
        $this->router->pattern('slug', '[a-z0-9-]+');
        $this->router->pattern('token', '[a-zA-Z0-9]{60}');

        // Allow full domain routing by including dots in the domain regex pattern. Same
        // use-case as subdomains, only this enables you to handle i.e. www.site1.com
        // and www.site2.com within the same Laravel application with a single route or
        // route group.
        $this->router->pattern('domain', '[a-z0-9.]+');
    }
941574
function routeIsActive(pathname, routes, params, indexOnly) {
  // TODO: This is a bit ugly. It keeps around support for treating pathnames
  // without preceding slashes as absolute paths, but possibly also works
  // around the same quirks with basenames as in matchRoutes.
  if (pathname.charAt(0) !== '/') {
    pathname = `/${pathname}`
  }

  const i = getMatchingRouteIndex(pathname, routes, params)

  if (i === null) {
    // No match.
    return false
  } else if (!indexOnly) {
    // Any match is good enough.
    return true
  }

  // If any remaining routes past the match index have paths, then we can't
  // be on the index route.
  return routes.slice(i + 1).every(route => !route.path)
}
492360
function map($url,$class,$ttl=0,$kbps=0) {
		if (is_array($url)) {
			foreach ($url as $item)
				$this->map($item,$class,$ttl,$kbps);
			return;
		}
		foreach (explode('|',self::VERBS) as $method)
			$this->route($method.' '.$url,is_string($class)?
				$class.'->'.$this->hive['PREMAP'].strtolower($method):
				array($class,$this->hive['PREMAP'].strtolower($method)),
				$ttl,$kbps);
	}
182366
function addMatch (route) {
  let routePath = route.path
  let paramNames = []
  let matched
  // find any paths prefixed with `:` or `%`, and treat them as capture groups
  while ((matched = routePath.match(paramPattern)) !== null) {
    routePath = routePath.replace(paramPattern, '([^?/]+)')
    paramNames.push(matched[1])
  }
  // if a route ends with `index`, allow matching that route without matching the `index` part
  if (path.basename(routePath) === 'index') {
    route.isIndex = true
    routePath = routePath.replace(/\/index$/, '/?([:%]?index)?')
  }
  // create a regex with our path
  let pattern = new RegExp(`^${routePath}(\\?(.*)|$)`, 'i')
  route.pattern = pattern
  route.match = url => {
    let m = url.match(pattern)
    if (m) {
      let params = paramNames.reduce((o, p, idx) => {
        o[p] = m[idx + 1]
        return o
      }, {})
      let query = qs.parse(m[m.length - 1])
      return { params, query }
    }
  }
  return route
}
1030826
function routesCode (pages) {
  function genRoute ({
    path: pagePath,
    key: componentName,
    frontmatter: {
      layout
    },
    regularPath,
    _meta
  }) {
    let code = `
  {
    name: ${JSON.stringify(componentName)},
    path: ${JSON.stringify(pagePath)},
    component: GlobalLayout,
    beforeEnter: (to, from, next) => {
      ensureAsyncComponentsLoaded(${JSON.stringify(layout || 'Layout')}, ${JSON.stringify(componentName)}).then(next)
    },${_meta ? `\n    meta: ${JSON.stringify(_meta)}` : ''}
  }`

    const dncodedPath = decodeURIComponent(pagePath)
    if (dncodedPath !== pagePath) {
      code += `,
  {
    path: ${JSON.stringify(dncodedPath)},
    redirect: ${JSON.stringify(pagePath)}
  }`
    }

    if (/\/$/.test(pagePath)) {
      code += `,
  {
    path: ${JSON.stringify(pagePath + 'index.html')},
    redirect: ${JSON.stringify(pagePath)}
  }`
    }

    if (regularPath !== pagePath) {
      code += `,
  {
    path: ${JSON.stringify(regularPath)},
    redirect: ${JSON.stringify(pagePath)}
  }`
    }

    return code
  }

  const notFoundRoute = `,
  {
    path: '*',
    component: GlobalLayout
  }`

  return (
    `export const routes = [${pages.map(genRoute).join(',')}${notFoundRoute}\n]`
  )
}
1071736
def setup_versioned_routes(routes, version=None):
    """"""
    prefix = '/' + version if version else ""
    for r in routes:
        path, method = r
        route(prefix + path, method, routes[r])
574923
function switchRouteMatcher(on, when) {
      // TODO(i): this code is convoluted and inefficient, we should construct the route matching
      //   regex only once and then reuse it
      var regex = '^' + when.replace(/([\.\\\(\)\^\$])/g, "\\$1") + '$',
          params = [],
          dst = {};
      forEach(when.split(/\W/), function(param) {
        if (param) {
          var paramRegExp = new RegExp(":" + param + "([\\W])");
          if (regex.match(paramRegExp)) {
            regex = regex.replace(paramRegExp, "([^\\/]*)$1");
            params.push(param);
          }
        }
      });
      var match = on.match(new RegExp(regex));
      if (match) {
        forEach(params, function(name, index) {
          dst[name] = match[index + 1];
        });
      }
      return match ? dst : null;
    }
532984
function routePath (route) {
  if (!route) return ''
  return route.path || (route.regexp && route.regexp.source) || ''
}