A simple helper to compiles the switch's "default" for both static and dynamic routes.
506036
private function compileSwitchDefault(bool $hasVars, bool $matchHost): string
    {
        if ($hasVars) {
            $code = <<<EOF

            foreach (\$vars as \$i => \$v) {
                if (isset(\$matches[1 + \$i])) {
                    \$ret[\$v] = \$matches[1 + \$i];
                }
            }

EOF;
        } elseif ($matchHost) {
            $code = <<<EOF

            if (\$requiredHost) {
                if ('#' !== \$requiredHost[0] ? \$requiredHost !== \$host : !preg_match(\$requiredHost, \$host, \$hostMatches)) {
                    break;
                }
                if ('#' === \$requiredHost[0] && \$hostMatches) {
                    \$hostMatches['_route'] = \$ret['_route'];
                    \$ret = \$this->mergeDefaults(\$hostMatches, \$ret);
                }
            }

EOF;
        } else {
            $code = '';
        }

        $code .= <<<EOF

            \$hasRequiredScheme = !\$requiredSchemes || isset(\$requiredSchemes[\$context->getScheme()]);
            if (\$requiredMethods && !isset(\$requiredMethods[\$canonicalMethod]) && !isset(\$requiredMethods[\$requestMethod])) {
                if (\$hasRequiredScheme) {
                    \$allow += \$requiredMethods;
                }
                break;
            }
            if (!\$hasRequiredScheme) {
                \$allowSchemes += \$requiredSchemes;
                break;
            }

            return \$ret;

EOF;

        return $code;
    }
1232103
protected void setDefaults() {
    // map.put("tsd.network.port", ""); // does not have a default, required
    // map.put("tsd.http.cachedir", ""); // does not have a default, required
    // map.put("tsd.http.staticroot", ""); // does not have a default, required
    default_map.put("tsd.mode", "rw");
    default_map.put("tsd.no_diediedie", "false");
    default_map.put("tsd.network.bind", "0.0.0.0");
    default_map.put("tsd.network.worker_threads", "");
    default_map.put("tsd.network.async_io", "true");
    default_map.put("tsd.network.tcp_no_delay", "true");
    default_map.put("tsd.network.keep_alive", "true");
    default_map.put("tsd.network.reuse_address", "true");
    default_map.put("tsd.core.authentication.enable", "false");
    default_map.put("tsd.core.authentication.plugin", "");
    default_map.put("tsd.core.auto_create_metrics", "false");
    default_map.put("tsd.core.auto_create_tagks", "true");
    default_map.put("tsd.core.auto_create_tagvs", "true");
    default_map.put("tsd.core.connections.limit", "0");
    default_map.put("tsd.core.enable_api", "true");
    default_map.put("tsd.core.enable_ui", "true");
    default_map.put("tsd.core.meta.enable_realtime_ts", "false");
    default_map.put("tsd.core.meta.enable_realtime_uid", "false");
    default_map.put("tsd.core.meta.enable_tsuid_incrementing", "false");
    default_map.put("tsd.core.meta.enable_tsuid_tracking", "false");
    default_map.put("tsd.core.meta.cache.enable", "false");
    default_map.put("tsd.core.plugin_path", "");
    default_map.put("tsd.core.socket.timeout", "0");
    default_map.put("tsd.core.tree.enable_processing", "false");
    default_map.put("tsd.core.preload_uid_cache", "false");
    default_map.put("tsd.core.preload_uid_cache.max_entries", "300000");
    default_map.put("tsd.core.storage_exception_handler.enable", "false");
    default_map.put("tsd.core.uid.random_metrics", "false");
    default_map.put("tsd.core.bulk.allow_out_of_order_timestamps", "false");
    default_map.put("tsd.query.filter.expansion_limit", "4096");
    default_map.put("tsd.query.skip_unresolved_tagvs", "false");
    default_map.put("tsd.query.allow_simultaneous_duplicates", "true");
    default_map.put("tsd.query.enable_fuzzy_filter", "true");
    default_map.put("tsd.query.limits.bytes.default", "0");
    default_map.put("tsd.query.limits.bytes.allow_override", "false");
    default_map.put("tsd.query.limits.data_points.default", "0");
    default_map.put("tsd.query.limits.data_points.allow_override", "false");
    default_map.put("tsd.query.limits.overrides.interval", "60000");
    default_map.put("tsd.query.multi_get.enable", "false");
    default_map.put("tsd.query.multi_get.limit", "131072");
    default_map.put("tsd.query.multi_get.batch_size", "1024");
    default_map.put("tsd.query.multi_get.concurrent", "20");
    default_map.put("tsd.query.multi_get.get_all_salts", "false");
    default_map.put("tsd.rpc.telnet.return_errors", "true");
    // Rollup related settings
    default_map.put("tsd.rollups.enable", "false");
    default_map.put("tsd.rollups.tag_raw", "false");
    default_map.put("tsd.rollups.agg_tag_key", "_aggregate");
    default_map.put("tsd.rollups.raw_agg_tag_value", "RAW");
    default_map.put("tsd.rollups.block_derived", "true");
    default_map.put("tsd.rtpublisher.enable", "false");
    default_map.put("tsd.rtpublisher.plugin", "");
    default_map.put("tsd.search.enable", "false");
    default_map.put("tsd.search.plugin", "");
    default_map.put("tsd.stats.canonical", "false");
    default_map.put("tsd.startup.enable", "false");
    default_map.put("tsd.startup.plugin", "");
    default_map.put("tsd.storage.hbase.scanner.maxNumRows", "128");
    default_map.put("tsd.storage.fix_duplicates", "false");
    default_map.put("tsd.storage.flush_interval", "1000");
    default_map.put("tsd.storage.hbase.data_table", "tsdb");
    default_map.put("tsd.storage.hbase.uid_table", "tsdb-uid");
    default_map.put("tsd.storage.hbase.tree_table", "tsdb-tree");
    default_map.put("tsd.storage.hbase.meta_table", "tsdb-meta");
    default_map.put("tsd.storage.hbase.zk_quorum", "localhost");
    default_map.put("tsd.storage.hbase.zk_basedir", "/hbase");
    default_map.put("tsd.storage.hbase.prefetch_meta", "false");
    default_map.put("tsd.storage.enable_appends", "false");
    default_map.put("tsd.storage.repair_appends", "false");
    default_map.put("tsd.storage.enable_compaction", "true");
    default_map.put("tsd.storage.compaction.flush_interval", "10");
    default_map.put("tsd.storage.compaction.min_flush_threshold", "100");
    default_map.put("tsd.storage.compaction.max_concurrent_flushes", "10000");
    default_map.put("tsd.storage.compaction.flush_speed", "2");
    default_map.put("tsd.timeseriesfilter.enable", "false");
    default_map.put("tsd.uid.use_mode", "false");
    default_map.put("tsd.uid.lru.enable", "false");
    default_map.put("tsd.uid.lru.name.size", "5000000");
    default_map.put("tsd.uid.lru.id.size", "5000000");
    default_map.put("tsd.uidfilter.enable", "false");
    default_map.put("tsd.core.stats_with_port", "false");
    default_map.put("tsd.http.show_stack_trace", "true");
    default_map.put("tsd.http.query.allow_delete", "false");
    default_map.put("tsd.http.header_tag", "");
    default_map.put("tsd.http.request.enable_chunked", "false");
    default_map.put("tsd.http.request.max_chunk", "4096");
    default_map.put("tsd.http.request.cors_domains", "");
    default_map.put("tsd.http.request.cors_headers", "Authorization, "
      + "Content-Type, Accept, Origin, User-Agent, DNT, Cache-Control, "
      + "X-Mx-ReqToken, Keep-Alive, X-Requested-With, If-Modified-Since");
    default_map.put("tsd.query.timeout", "0");
    default_map.put("tsd.storage.use_otsdb_timestamp", "false");
    default_map.put("tsd.storage.use_max_value", "true");
    default_map.put("tsd.storage.get_date_tiered_compaction_start", "0");

    for (Map.Entry<String, String> entry : default_map.entrySet()) {
      if (!properties.containsKey(entry.getKey()))
        properties.put(entry.getKey(), entry.getValue());
    }

    loadStaticVariables();
  }
1055721
def transmute_route(app, fn, context=default_context):
    
    transmute_func = TransmuteFunction(fn)
    routes, handler = create_routes_and_handler(transmute_func, context)
    for r in routes:
        """
        the route being attached is a great place to start building up a
        swagger spec.  the SwaggerSpec object handles creating the
        swagger spec from transmute routes for you.

        almost all web frameworks provide some app-specific context
        that one can add values to. It's recommended to attach
        and retrieve the swagger spec from there.
        """
        if not hasattr(app, SWAGGER_ATTR_NAME):
            setattr(app, SWAGGER_ATTR_NAME, SwaggerSpec())
        swagger_obj = getattr(app, SWAGGER_ATTR_NAME)
        swagger_obj.add_func(transmute_func, context)
        app.route(r, methods=transmute_func.methods)(handler)
533801
async function _default(config, routesConfig) {
  const res = await (0, _startApp.default)(config);
  const {
    url,
    app,
    router,
    middleware,
    connect
  } = res;
  let methods;

  if (routesConfig) {
    methods = await (0, _routes.initRoutes2)(routesConfig, middleware, router);
    const routes = router.routes();
    app.use(routes);
  }

  return {
    url,
    app,
    connect,
    methods,
    router
  };
}
1256385
function getConfig(context, options, extendsDefaults) {
  const defaults = getDefaults(context, options);
  const config = $.config(options, defaults, (typeof extendsDefaults !== `boolean`) || extendsDefaults);
  config.metadata = { global: config.metadata, collections: {
    'error-pages': {
      pattern: `**/{500,404}.*`,
      metadata: {
        permalink: false
      }
    }
  }};
  return config;
}
207122
function(options={}, callback=function(){}) {

    // Let all of our components always have referance to our router
    Component.prototype.router = this;

    // Save our config referance
    this.config = options;
    this.config.handlers = [];
    this.config.containers = [];

    // Normalize our url configs
    this.config.root = normalizeUrl(this.config.root);
    this.config.assetRoot = this.config.assetRoot ? normalizeUrl(this.config.assetRoot) : this.config.root;
    this.config.jsPath = normalizeUrl(this.config.assetRoot, this.config.jsPath);
    this.config.cssPath = normalizeUrl(this.config.assetRoot, this.config.cssPath);

    // Get a unique instance id for this router
    this.uid = $.uniqueId('router');

    // Allow user to override error route
    this.config.errorRoute && (ERROR_ROUTE_NAME = this.config.errorRoute);

    // Convert our routeMappings to regexps and push to our handlers
    _.each(this.config.routeMapping, function(value, route){
      var regex = this._routeToRegExp(route);
      this.config.handlers.unshift({ route: route, regex: regex, app: value });
    }, this);

    // Use the user provided container, or default to the closest `<main>` tag
    this.config.container = $((this.config.container || 'main'))[0];
    this.config.containers.push(this.config.container);
    SERVICES.page = new ServiceLoader('page');

    // Install our global components
    _.each(this.config.services, function(selector, route){
      var container = $(selector)[0] || document.createElement('span');
      this.config.containers.push(container);
      SERVICES[route] = new ServiceLoader(route);
      this._fetchResource(route, container).catch(function(){});
    }, this);

    // Watch click events on links in all out containers
    this._watchLinks(this.config.containers);

    // Start the history and call the provided callback
    Backbone.history.start({
      pushState: (this.config.pushState === undefined) ? true : this.config.pushState,
      root: (this.config.root || '')
    }).then(callback);

    return this;
  }
508600
private function compile()
    {
        $options = $replaces = [];
        $pattern = rtrim(ltrim($this->pattern, ':/'), '/');

        // correct [/ first occurrence]
        if (strpos($pattern, '[/') === 0) {
            $pattern = '[' . substr($pattern, 2);
        }

        if (preg_match_all('/<(\w+):?(.*?)?>/', $pattern, $matches)) {
            $variables = array_combine($matches[1], $matches[2]);

            foreach ($variables as $key => $segment) {
                $segment = $this->prepareSegment($key, $segment);
                $replaces["<$key>"] = "(?P<$key>$segment)";
                $options[] = $key;
            }
        }

        $template = preg_replace('/<(\w+):?.*?>/', '<\1>', $pattern);
        $options = array_fill_keys($options, null);

        foreach ($this->constrains as $key => $value) {
            if ($value instanceof Autofill) {
                // only forces value replacement, not required to be presented as parameter
                continue;
            }

            if (!array_key_exists($key, $options)) {
                throw new ConstrainException(sprintf(
                    "Route `%s` does not define routing parameter `<%s>`.",
                    $this->pattern,
                    $key
                ));
            }
        }

        $this->compiled = '/^' . strtr($template, $replaces + self::PATTERN_REPLACES) . '$/iu';
        $this->template = stripslashes(str_replace('?', '', $template));
        $this->options = $options;
    }
1332982
def define_localized_url_helper(route, name, kind, options)
      if n = localizable
        selector = url_helper_name(name, kind)

        rlang = if n.kind_of?(ActionDispatch::Routing::Mapper::Resources::Resource) and i = name.to_s.rindex("_#{n.plural}")
                  "#{selector.to_s[0, i]}_glang_#{n.plural}#{selector.to_s[i + "_#{n.plural}".size, selector.to_s.size]}"
                elsif n.kind_of?(ActionDispatch::Routing::Mapper::Resources::Resource) and i = name.to_s.rindex("_#{n.singular}")
                  "#{selector.to_s[0, i]}_glang_#{n.singular}#{selector.to_s[i + "_#{n.singular}".size, selector.to_s.size]}"
                else
                  "glang_#{selector}"
                end

        @module.module_eval <<-end_eval # We use module_eval to avoid leaks
          alias_method :localized_#{selector}, :#{selector}

          def #{selector}(*args)
            selector_g = '#{rlang}'.gsub('glang', I18nRouting.locale_escaped(I18n.locale.to_s)).to_sym

            #puts "Call routes : #{selector} => \#{selector_g} (\#{I18n.locale}) "
            if respond_to? selector_g and selector_g != :#{selector}
              send(selector_g, *args)
            else
              localized_#{selector}(*args)
            end
          end

        end_eval

      end
    end
1176846
function (name) {
      var route = _containerOwner.getOwner(this).lookup('route:' + name);

      if (!route) {
        return {};
      }

      var transition = this.router.router.activeTransition;
      var state = transition ? transition.state : this.router.router.state;

      var params = {};
      _emberMetalAssign.default(params, state.params[name]);
      _emberMetalAssign.default(params, getQueryParamsFor(route, state));

      return params;
    }
1139664
function (reInit = false) {
        //load routes
        var environment = Shared.config("environment");
        var hosts = environment.hosts;
        if (hosts) {
            if (!_.isArray(hosts)) {
                hosts = [hosts];
            }
            for (var host in hosts) {
                _parseHosts(hosts[host], reInit);
            }
        }
        _vhosts["*"] = {
            host: '*',
            router: new express.Router()
        };

        _applyRouterConfig(_vhosts["*"]["router"]);
        _customInitFuncton(_vhosts["*"]["router"]);

        return RoutesHandler.initializeRoutes(_vhosts, reInit === false);
    }
715065
function routeSolver(routeItem, handler, resolver) {
    switch (typeof handler) {
    case 'function':
        // solve as function handler
        registerHandler(routeItem, null, routeItem.handler);
        break;
    case 'string':
        // solve as controller - action handler
        resolver(routeItem, handler);
        break;
    default:
        throw new Error('unknow route type');
    }
}
3697
function getDefaultOpts(simple) {
  'use strict';

  var defaultOptions = {
    omitExtraWLInCodeBlocks: {
      defaultValue: false,
      describe: 'Omit the default extra whiteline added to code blocks',
      type: 'boolean'
    },
    noHeaderId: {
      defaultValue: false,
      describe: 'Turn on/off generated header id',
      type: 'boolean'
    },
    prefixHeaderId: {
      defaultValue: false,
      describe: 'Specify a prefix to generated header ids',
      type: 'string'
    },
    headerLevelStart: {
      defaultValue: false,
      describe: 'The header blocks level start',
      type: 'integer'
    },
    parseImgDimensions: {
      defaultValue: false,
      describe: 'Turn on/off image dimension parsing',
      type: 'boolean'
    },
    simplifiedAutoLink: {
      defaultValue: false,
      describe: 'Turn on/off GFM autolink style',
      type: 'boolean'
    },
    excludeTrailingPunctuationFromURLs: {
      defaultValue: false,
      describe: 'Excludes trailing punctuation from links generated with autoLinking',
      type: 'boolean'
    },
    literalMidWordUnderscores: {
      defaultValue: false,
      describe: 'Parse midword underscores as literal underscores',
      type: 'boolean'
    },
    strikethrough: {
      defaultValue: false,
      describe: 'Turn on/off strikethrough support',
      type: 'boolean'
    },
    tables: {
      defaultValue: false,
      describe: 'Turn on/off tables support',
      type: 'boolean'
    },
    tablesHeaderId: {
      defaultValue: false,
      describe: 'Add an id to table headers',
      type: 'boolean'
    },
    ghCodeBlocks: {
      defaultValue: true,
      describe: 'Turn on/off GFM fenced code blocks support',
      type: 'boolean'
    },
    tasklists: {
      defaultValue: false,
      describe: 'Turn on/off GFM tasklist support',
      type: 'boolean'
    },
    smoothLivePreview: {
      defaultValue: false,
      describe: 'Prevents weird effects in live previews due to incomplete input',
      type: 'boolean'
    },
    smartIndentationFix: {
      defaultValue: false,
      description: 'Tries to smartly fix indentation in es6 strings',
      type: 'boolean'
    },
    disableForced4SpacesIndentedSublists: {
      defaultValue: false,
      description: 'Disables the requirement of indenting nested sublists by 4 spaces',
      type: 'boolean'
    },
    simpleLineBreaks: {
      defaultValue: false,
      description: 'Parses simple line breaks as <br> (GFM Style)',
      type: 'boolean'
    },
    requireSpaceBeforeHeadingText: {
      defaultValue: false,
      description: 'Makes adding a space between `#` and the header text mandatory (GFM Style)',
      type: 'boolean'
    }
  };
  if (simple === false) {
    return JSON.parse(JSON.stringify(defaultOptions));
  }
  var ret = {};
  for (var opt in defaultOptions) {
    if (defaultOptions.hasOwnProperty(opt)) {
      ret[opt] = defaultOptions[opt].defaultValue;
    }
  }
  return ret;
}
1243028
function () {
      if (this.state) {
        _routerUtils.forEach(this.state.handlerInfos.slice().reverse(), function (handlerInfo) {
          var handler = handlerInfo.handler;
          _routerUtils.callHook(handler, 'exit');
        });
      }

      this.state = new _routerTransitionState.default();
      this.currentHandlerInfos = null;
    }
1596
def _compile(self):
        '''  '''
        self.static = {}
        self.dynamic = []
        def fpat_sub(m):
            return m.group(0) if len(m.group(1)) % 2 else m.group(1) + '(?:'
        for rule in self.rules:
            target = self.routes[rule]
            if not self.syntax.search(rule):
                self.static[rule.replace('\\:',':')] = target
                continue
            gpat = self._compile_pattern(rule)
            fpat = re.sub(r'(\\*)(\(\?P<[^>]*>|\((?!\?))', fpat_sub, gpat.pattern)
            gpat = gpat if gpat.groupindex else None
            try:
                combined = '%s|(%s)' % (self.dynamic[-1][0].pattern, fpat)
                self.dynamic[-1] = (re.compile(combined), self.dynamic[-1][1])
                self.dynamic[-1][1].append((gpat, target))
            except (AssertionError, IndexError) as e: # AssertionError: Too many groups
                self.dynamic.append((re.compile('(^%s$)'%fpat),
                                    [(gpat, target)]))
            except re.error as e:
                raise RouteSyntaxError("Could not add Route: %s (%s)" % (rule, e))
78176
function FrontRouter() {
    var opts = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0];

    _classCallCheck(this, FrontRouter);

    this.options = {
      pageRoot: opts.pageRoot || process.cwd(),
      overwrite: opts.overwrite || false
    };
    this.routes = [];

    // Figure out what library to load
    switch (_typeof(opts.library)) {
      // String: pull a library out of the built-in ones
      case 'string':
        {
          var lib = Libraries[opts.library];
          if (typeof lib === 'undefined') {
            throw new Error('Front Router: there\'s no built-in plugin for "' + opts.library + '"');
          } else {
            this.options.library = lib;
          }
          break;
        }
      // Function: add as-is
      case 'function':
        {
          this.options.library = opts.library;
          break;
        }
      // Nothing: use the default library adapter
      case 'undefined':
        {
          this.options.library = Libraries.default;
          break;
        }
      // Other weird values? Nope
      default:
        {
          throw new Error('Front Router: library must be a string or function.');
        }
    }
  }
915034
private void configureDefaultContextPath(DefaultContextPath dcp) {
        String methodName = "configureDefaultContextPath";
        String defaultContextPath = dcp.getValue();

        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
            Tr.debug(tc, methodName + ": defaultContextPath --> " + defaultContextPath);
        }

        if (defaultContextPath != null && !defaultContextPath.isEmpty()) {
            webAppConfiguration.setDefaultContextPath(defaultContextPath);
        }
    }
705699
function genRoute(path, breadcrumbName, baseComponent, parentPath) {
  return {
    path,
    exact: true,
    baseComponent,
    breadcrumbName,
    parentPath
  }
}