Get info for particular route
@param appName
@param urlRequest
@param query
@param lang
@param user
@param referrer
@returns {{}} The routeInfo for a particular request
760208
function getRouteInfo(appName, urlRequest, query, lang, user, referrer) {

    var activeUser = user ? {
        _id: user._id,
        name: user.username,
        role: user.role,
        user: user
    } : {};

    // if route info already in cache, return it
    var cacheKey = appName + '||' + lang + '||' + urlRequest;
    var cachedRouteInfo = routeInfoCache[cacheKey];
    if (!user && cachedRouteInfo) {
        cachedRouteInfo.query = query;  // query shouldn't be cached
        return cachedRouteInfo;
    }

    // if urlRequest ends in .html it is an amp request so treat it as such
    var isAmp = /\.html$/.test(urlRequest);
    if (isAmp) {
        urlRequest = urlRequest.substring(0, urlRequest.length - 5);
    }

    // get the routes and then find the info that matches the current URL
    var url = urlRequest.toLowerCase();
    var i, route, routeInfo;
    var routes = getRoutes(appName);
    if (routes) {
        // loop through routes trying to find the one that matches
        for (i = 0; i < routes.length; i++) {
            route = routes[i];
            // if there is a match, save the info to cache and return it
            if (route.urlRegex.test(url)) {
                routeInfo = _.extend({
                    appName:    appName,
                    referrer:   referrer,
                    lang:       lang,
                    url:        urlRequest,
                    query:      query,
                    activeUser: activeUser,
                    isAmp:      isAmp,
                    tokens:     getTokenValuesFromUrl(route.urlPattern, urlRequest)
                }, route);

                // change layout wrapper to amp if request is for amp
                if (isAmp) {
                    routeInfo.wrapper = 'amp';
                }

                // if no user, then save request in cache
                if (!user) {
                    routeInfoCache[cacheKey] = routeInfo;
                }

                return routeInfo;
            }
        }
    }

    // if we get here, then no route found, so throw 404 error
    throw new Error('404: ' + appName + ' ' + urlRequest + ' is not a valid request');
}
195599
public function constructUrl(Request $appRequest, Url $refUrl)
	{
		// Module prefix not match.
		if ($this->module && !Strings::startsWith($appRequest->getPresenterName(), $this->module)) {
			return null;
		}

		$parameters = $appRequest->getParameters();
		$urlStack = array();

		// Module prefix.
		$moduleFrags = explode(":", $appRequest->getPresenterName());

		if (count($moduleFrags)) {
			foreach($moduleFrags as &$fragment) {
				$fragment = $this->presenter2path($fragment);
			}
		}

		$resourceName = array_pop($moduleFrags);
		$urlStack += $moduleFrags;

		if (isset($parameters['associations']) && is_array($parameters['associations'])) {
			$associations = & $parameters['associations'];

			foreach ($associations as $key => $value) {
				$urlStack[] = $key;
				$urlStack[] = $value;
			}
		}

		$urlStack[] = $resourceName;
		if(isset($parameters['specific_action']) && $parameters['specific_action']) {
			$urlStack[] = $this->action2path($parameters['specific_action']);
		}

		if (isset($parameters['id']) && is_scalar($parameters['id'])) {
			$urlStack[] = $parameters['id'];
		}

		$url = $q = $refUrl->getBaseUrl() . implode('/', $urlStack);


		if(isset($parameters['query']) && count($parameters['query'])) {
			$sep = ini_get('arg_separator.input');
			$query = http_build_query($parameters['query'], '', $sep ? $sep[0] : '&');
			$url .= '?' . $query;
		}

		return $url;
	}
273417
function(route, name, callback) {
    if (_.isFunction(name)) {
      callback = name;
      name = '';
    }

    if (!_.isRegExp(route)){
      route = this._routeToRegExp(route);
    }

    if (!callback){ callback = this[name]; }
    Backbone.history.route(route, (fragment) => {

      // If this route was defined as a regular expression, we don't capture
      // query params. Only parse the actual path.
      fragment = fragment.split('?')[0];

      // Extract the arguments we care about from the fragment
      var args = this._extractParameters(route, fragment);

      // Get the query params string
      var search = (Backbone.history.getSearch() || '').slice(1);

      // If this route was created from a string (not a regexp), remove the auto-captured
      // search params.
      if(route._isString){ args.pop(); }

      // If the route is not user prodided, if the history object has search params
      // then our args have the params as its last agrument as of Backbone 1.2.0
      // If the route is a user provided regex, add in parsed search params from
      // the history object before passing to the callback.
      args.push((search) ? $.url.query.parse(search) : {});

      var resp = this.execute(callback, args, name);
      if ( resp !== false) {
        this.trigger.apply(this, ['route:' + name].concat(args));
        this.trigger('route', name, args);
        Backbone.history.trigger('route', this, name, args);
      }
      return resp;
    });
    return this;
  }
637906
function Request__getRouteInfo() {
        return {
            id: this.id,
            url: this.url,
            controller: this.controller,
            action: this.action,
            module: this.module,
            params: this.params,
            method: this.getMethod(),
            requestDomain: this.getRequestDomain(),
            remoteAddress: this.getRequestRemoteAddress(),
            remotePort: this.getRequestRemotePort(),
            localAddress: this.getRequestLocalAddress(),
            localPort: this.getRequestLocalPort()
        };
    }
717314
public static function localGetPart(string $appname, array $webroutes, string $stringwebroute):?array
    {
        if (true === Locale::isEnabled()) {
            $lapp = new AppLocale($appname);
            if (true === $lapp->isEnabled()) {
                foreach ($lapp->getValues() as $one) {
                    $comp = $webroutes[0] ?? null;
                    if (true === is_object($one)) {
                        foreach ((array)$one as $second) {
                            if ($comp === $second) {
                                array_unshift($webroutes, $second);
                                $webroutes = array_values(array_diff($webroutes, array($second)));
                                $stringwebroute = str_replace("/$second/", "/", $stringwebroute);
                                return (["locale" => $second, "object" => $lapp,
                                    "full_webroute" => $stringwebroute, "array_webroute" => $webroutes]);
                            }
                        }
                    } elseif ($one === $comp) {
                        $webroutes = array_values(array_diff($webroutes, array($comp)));
                        $stringwebroute = str_replace("/$comp/", "/", $stringwebroute);
                        return (["locale" => $one, "object" => $lapp,
                            "full_webroute" => $stringwebroute, "array_webroute" => $webroutes]);
                    }
                }
            }
        }
        return (null);
    }
1171155
function getUrlGETparams() {
    var vars = {}, hash;
    var hashes = window.location.href.slice( window.location.href.indexOf('?') + 1 ).split('&');
    for( var i = 0; i < hashes.length; i++ ) {
        hash = hashes[i].split('=');
        vars[ hash[0] ] = hash[1];
        // switch on console logging
        if ( hash[0] == 'info') { logInfo = true  }
        if ( hash[0] == 'info' && hash[1] && hash[1] != '') { logInfoStr = hash[1] }
    }
    //alert( JSON.stringify( vars )  );
    return vars;
}
6667
function processWebRequest(routeInfo, callbacks) {
    var appName = routeInfo.appName;
    var serverOnly = !!routeInfo.query.server;
    var page = injector.loadModule('app/' + appName + '/pages/' + routeInfo.name + '.page');

    // get the callbacks
    var serverPreprocessing = callbacks.serverPreprocessing || function () { return false; };
    var appAddToModel = callbacks.addToModel || function () {};
    var pageCacheService = callbacks.pageCacheService || defaultPageCache;
    var initialModel, cacheKey;

    return getInitialModel(routeInfo, page)
        .then(function (model) {
            initialModel = model || {};

            // if the server pre-processing returns true, then return without doing anything
            // this is because the pre-processor sent a reply to the user already
            if (serverPreprocessing(routeInfo, page, model)) {
                return true;
            }

            //TODO: may be weird edge cases with this. need to test more to ensure performance and uniqueness
            // but note that we have an hour default timeout for the redis cache just in case
            // and we have the redis LRU config set up so the least recently used will get pushed out
            cacheKey = utensils.checksum(routeInfo.lang + '||' + routeInfo.appName + '||' +
                routeInfo.url + '||' + JSON.stringify(model));

            return pageCacheService.get({ key: cacheKey });
        })
        .then(function (cachedPage) {
            if (cachedPage === true) { return null; }
            if (cachedPage && !serverOnly) { return cachedPage; }

            // allow the app level to modify the model before rendering
            appAddToModel(initialModel, routeInfo);

            // finally use the client side plugin to do the rendering
            return clientPlugin.renderPage(routeInfo, page, initialModel, inlineCssCache[appName + '||' + routeInfo.name]);
        })
        .then(function (renderedPage) {
            if (!serverOnly && renderedPage) {
                pageCacheService.set({ key: cacheKey, value: renderedPage });
            }

            return renderedPage;
        });
}
535972
function fetchLanguage ( url, language ) {
	const part = url.split('/'); part.pop();
	return got(normalizeUrl(`${API_URL}/${path.join(part.join('/'))}/${language}`));
}
44449
def app_resolver(app_name=None, pattern_kwargs=None, name=None):
    '''
    
    '''
    urlconf = URLConf(app_name, pattern_kwargs)
    resolver = re_path(
        '^{}/?'.format(app_name) if app_name is not None else '',
        include(urlconf),
        name=urlconf.app_name,
    )
    # this next line is a workaround for Django's URLResolver class not having
    # a `name` attribute, which is expected in Django's technical_404.html.
    resolver.name = getattr(resolver, 'name', name or app_name)
    return resolver
550916
function findMbaasApp(req, res, next){
  log.logger.debug("findMbaasApp for appname " + req.params.appname);
  getMbaasApp({
    '$or': [{name: req.params.appname}, {guid: req.params.appname}]
  }, function(err, appMbaas){
    if(err){
      log.logger.debug("findMbaasApp Error ", err);
      return next(err);
    }

    req.appMbaasModel = appMbaas;

    return next();
  });
}
960912
function getQueryParams(params) {
        params = params || {};
        var url = $location.url();
        var idx = url.indexOf('?');

        // if there is a query string
        if (idx < 0) { return {}; }

        // get the query string and split the keyvals
        var query = url.substring(idx + 1);
        var keyVals = query.split('&');

        // put each key/val into the params object
        _.each(keyVals, function (keyVal) {
            var keyValArr = keyVal.split('=');
            params[keyValArr[0]] = keyValArr[1];
        });

        return params;
    }
355270
function reqToAppName(req) {
  var targetName = null;
  try {
    targetName = req.url.split('/').pop();
  } catch (e) {}
  return targetName || null;
}
636205
function getBrowserInfo() {
  const ua = navigator.userAgent;
  let M =
    ua.match(/(opera|chrome|safari|firefox|msie|trident(?=\/))\/?\s*(\d+)/i) ||
    [];
  let tem;

  if (/trident/i.test(M[1])) {
    tem = /\brv[ :]+(\d+)/g.exec(ua) || [];

    return `IE ${tem[1] || ''}`;
  }

  if (M[1] === 'Chrome') {
    tem = ua.match(/\b(OPR|Edge)\/(\d+)/);
    if (tem !== null) {
      return tem
        .slice(1)
        .join(' ')
        .replace('OPR', 'Opera');
    }
  }

  M = M[2] ? [M[1], M[2]] : [navigator.appName, navigator.appVersion, '-?'];
  if ((tem = ua.match(/version\/(\d+)/i)) !== null) {
    M.splice(1, 1, tem[1]);
  }

  return M.join(' ');
}
1114968
function (path, query, cb) {
    var httpMethod = 'get',
        config = User.datastore.config,
        endpoint = url.format({
                    host: config.host,
                    pathname: path,
                    protocol: config.protocol,
                    query: query
                  }),
        req = request[httpMethod](endpoint);
    req.end(cb);
  }
1016327
URL parseLocalRefUrl(
            final HttpServletRequest request, final String refUrl) {
        URL rslt = null; // default
        if (StringUtils.isNotBlank(refUrl)) {
            try {
                final URL context = new URL(request.getRequestURL().toString());
                final URL location = new URL(context, refUrl);

                if (location.getProtocol().equals(context.getProtocol())
                        && location.getHost().equals(context.getHost())
                        && location.getPort() == context.getPort()) {
                    rslt = location;
                } else {
                    log.warn("The specified refUrl is not local:  " + refUrl);
                }
            } catch (Exception e) {
                log.warn("Unable to analyze specified refUrl:  " + refUrl);
                log.debug(e);
            }
        }
        return rslt;
    }
121807
def get_url(self, routename, **kargs):
        
        scriptname = request.environ.get('SCRIPT_NAME', '').strip('/') + '/'
        location = self.router.build(routename, **kargs).lstrip('/')
        return urljoin(urljoin('/', scriptname), location)
557440
function getURLFromRequest(request) {
	const queryString = makeQueryString(request.query || {});
	let formatted = request.route;
	let value;
	let regexp;

	// Replace route params with their values. If the route param is specified
	// with an extension (e.g., ':id.json'), keep the extension.
	Object.keys(request.params || {}).forEach((name) => {
		value = request.params[name];
		regexp = new RegExp(':' + name + '(?=(?:\\.|\\/|$|\\?))');
		formatted = formatted.replace(regexp, value);
	});

	return formatted + (queryString ? '?' + queryString : '');
}