Parse the hash and divides it into shellCreator, route and parameters

@param route ths hash to parse
@return parse result
@throws com.github.nalukit.nalu.client.internal.route.RouterException in case no controller is found for the routing
485417
public RouteResult parse(String route)
      throws RouterException {
    RouteResult routeResult = new RouteResult();
    String routeValue = route;
    // only the part after the first # is intresting:
    if (routeValue.contains("#")) {
      routeValue = routeValue.substring(routeValue.indexOf("#") + 1);
    }
    // extract shellCreator first:
    if (routeValue.startsWith("/")) {
      routeValue = routeValue.substring(1);
    }
    // check, if there are more "/"
    if (routeValue.contains("/")) {
      routeResult.setShell("/" +
                           routeValue.substring(0,
                                                routeValue.indexOf("/")));
    } else {
      routeResult.setShell("/" + routeValue);
    }
    // check, if the shellCreator exists ....
    Optional<String> optional = this.shellConfiguration.getShells()
                                                       .stream()
                                                       .map(ShellConfig::getRoute)
                                                       .filter(f -> f.equals(routeResult.getShell()))
                                                       .findAny();
    if (optional.isPresent()) {
      routeResult.setShell(optional.get());
    } else {
      StringBuilder sb = new StringBuilder();
      sb.append("no matching shellCreator found for route >>")
        .append(route)
        .append("<< --> Routing aborted!");
      RouterLogger.logSimple(sb.toString(),
                             1);
      throw new RouterException(sb.toString());
    }
    // extract route first:
    routeValue = route;
    if (routeValue.startsWith("/")) {
      routeValue = routeValue.substring(1);
    }
    if (routeValue.contains("/")) {
      String searchRoute = routeValue;
      Optional<RouteConfig> optionalRouterConfig = this.routerConfiguration.getRouters()
                                                                           .stream()
                                                                           .filter(rc -> Nalu.match(searchRoute,
                                                                                                    rc.getRoute()))
                                                                           .findFirst();
      if (optionalRouterConfig.isPresent()) {
        routeResult.setRoute(optionalRouterConfig.get()
                                                 .getRoute());
        if (routeResult.getRoute()
                       .contains("*")) {
          String[] partsOfRoute = routeValue.split("/");
          String compareRoute = optionalRouterConfig.get()
                                                    .getRoute();
          if (compareRoute.startsWith("/")) {
            compareRoute = compareRoute.substring(1);
          }
          String[] partsOfRouteFromConfiguration = compareRoute.split("/");
          for (int i = 0; i < partsOfRouteFromConfiguration.length; i++) {
            if (partsOfRouteFromConfiguration[i].equals("*")) {
              if (partsOfRoute.length - 1 >= i) {
                String parameterValue = partsOfRoute[i].replace(AbstractRouter.NALU_SLASH_REPLACEMENT,
                                                                "/");
                if (Nalu.isUsingColonForParametersInUrl()) {
                  if (parameterValue.length() > 0) {
                    if (parameterValue.startsWith(":")) {
                      parameterValue = parameterValue.substring(1);
                    }
                  }
                }
                routeResult.getParameterValues()
                           .add(parameterValue);
              } else {
                routeResult.getParameterValues()
                           .add("");
              }
            }
          }
        }
      } else {
        StringBuilder sb = new StringBuilder();
        sb.append("no matching route found for route >>")
          .append(route)
          .append("<< --> Routing aborted!");
        RouterLogger.logSimple(sb.toString(),
                               1);
        throw new RouterException(sb.toString());
      }
    } else {
      String finalSearchPart = "/" + routeValue;
      if (this.routerConfiguration.getRouters()
                                  .stream()
                                  .anyMatch(f -> f.match(finalSearchPart))) {
        routeResult.setRoute("/" + routeValue);
      } else {
        throw new RouterException(RouterLogger.logNoMatchingRoute(route));
      }
    }
    return routeResult;
  }
172932
public static String getControllerForResult(Route route) {
        if (route == null || route.getController() == null) return Constants.ROOT_CONTROLLER_NAME;
        return RouterHelper.getReverseRouteFast(route.getController()).substring(1);
    }
1275445
private final Route calculateRoute(HttpMethod httpMethod, String requestUri/*, ActionInvoker invoker*//*,Injector injector*/) throws RouteException {
        if (routes == null) throw new IllegalStateException("Routes have not been compiled. Call #compileRoutes() first");
        
        final Route route = matchCustom(httpMethod, requestUri);
        if (route != null) return route;
        
        // nothing is found - try to deduce a route from controllers
        //if (isDev) {
            try {
                return matchStandard(httpMethod, requestUri, invoker/*injector*/);
            } catch (ClassLoadException e) {
                // a route could not be deduced
            }
        //}
        
        throw new RouteException("Failed to map resource to URI: " + requestUri);
    }
625136
public static function execute($currentRoute)
    {
        $currentRouteParts = explode('/', $currentRoute);

        foreach (self::$routes as $route) {

            // Check if route matches complete URL.
            if ($route['url'] == $currentRoute) {
                return self::callController($route);
            }

            // Exploding route parts for dynamic checking.
            $routeParts = explode('/', $route['url']);

            // If route parts does not match current URL parts, continue.
            if (count($currentRouteParts) !== count($routeParts)) {
                continue;
            }

            $parts = count($routeParts) - 1;
            $valid = true;
            $properties = [];

            foreach ($routeParts as $key => $routePart) {
                $dynamicRoute = false;

                // Current route is not valid, continuing.
                if (! $valid) {
                    continue;
                }

                // Current route part is dynamic, add to array.
                if (substr($routePart, 0, 1) == '{' && substr($routePart, -1, 1) == '}') {
                    $properties[substr($routePart, 1, -1)] = $currentRouteParts[$key];
                    $dynamicRoute = true;
                }

                // If is not dynamic part, and does not match current URL part, make route invalid and continue.
                if (! $dynamicRoute && $routePart != $currentRouteParts[$key]) {
                    $valid = false;
                    continue;
                }

                // Check passed, call controller for current route.
                if ($key == $parts && $valid == true) {
                    return self::callController($route, $properties);
                }
            }
        }

        // No valid route for current route, throw exception.
        throw new RouteNotFoundException($currentRoute);
    }
652898
function () {
        var rootURL = this._getRootURL();
        var path = this._getPath();
        var hash = this._getHash();
        var query = this._getQuery();
        var rootURLIndex = path.indexOf(rootURL);
        var routeHash, hashParts;

        Ember.assert('Path ' + path + ' does not start with the provided rootURL ' + rootURL, rootURLIndex === 0);

        // By convention, Ember.js routes using HashLocation are required to start
        // with `#/`. Anything else should NOT be considered a route and should
        // be passed straight through, without transformation.
        if (hash.substr(0, 2) === '#/') {
          // There could be extra hash segments after the route
          hashParts = hash.substr(1).split('#');
          // The first one is always the route url
          routeHash = hashParts.shift();

          // If the path already has a trailing slash, remove the one
          // from the hashed route so we don't double up.
          if (path.slice(-1) === '/') {
              routeHash = routeHash.substr(1);
          }

          // This is the "expected" final order
          path += routeHash;
          path += query;

          if (hashParts.length) {
            path += '#' + hashParts.join('#');
          }
        } else {
          path += query;
          path += hash;
        }

        return path;
      }
601758
private function generateHashForUrl($key, $route, $method)
    {
        $path = preg_replace('~\s+~', '-', $key);
        $httpMethod = $this->getRouteParam($route, 'methods.0');
        $classMethod = implode('-', $this->splitCamelCaseToWords($method));
        
        $hash = $path .'::'. $httpMethod .'::'. $classMethod;
        
        return strtolower($hash);
    }
61427
def process_route(pattern, keys, conditions, block = nil, values = [])
      route = @request.path_info
      route = '/' if route.empty? and not settings.empty_path_info?
      return unless match = pattern.match(route)
      values += match.captures.to_a.map { |v| force_encoding URI.decode_www_form_component(v) if v }

      if values.any?
        original, @params = params, params.merge('splat' => [], 'captures' => values)
        keys.zip(values) { |k,v| Array === @params[k] ? @params[k] << v : @params[k] = v if v }
      end

      catch(:pass) do
        conditions.each { |c| throw :pass if c.bind(self).call == false }
        block ? block[self, values] : yield(self, values)
      end
    ensure
      @params = original if original
    end
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
143197
private function _parse_routes()
	{
		$uri=implode('/', $this->uri->segments());

		if (isset($this->router[$uri])) {
			return $this->_set_request(explode('/', $this->router[$uri]));
		}

		foreach ($this->router as $key => $val) {
			$key = str_replace(':any', '.+', str_replace(':num', '[0-9]+', $key));

			if (preg_match('#^'.$key.'$#', $uri)) {
				if (strpos($val, '$') !== FALSE AND strpos($key, '(') !== FALSE) {
					$val = preg_replace('#^'.$key.'$#', $val, $uri);
				}

				return $this->_set_request(explode('/', $val));
			}
		}

		$this->_set_request($this->uri->segments());
	}
69215
public function handle(ParsedRoute $route)
    {
        $segments = explode("::", $route->controller());
        $controller = $segments[0];
        $action = count($segments) > 1 ? $segments[1] : "index";
        if (method_exists($controller, $action)) {
            $params = [$route->params()];
            return call_user_func_array([new $controller, $action], $params);
        }

        throw new RuntimeException("No method {$action} in controller {$segments[0]}");
    }
1147683
public function parseGetRoute()
    {
        $request = $this->getRequest();

        if (is_null($request) || ! isset($this->routes['get'])) {
            return;
        }

        $action = $request->get('action', '/');

        if (in_array($action, array_keys($this->routes['get']))) {
            $callback = $this->routes['get'][$action];
            $response = $this->handleCallback($callback);

            if (! is_a($response, Renderable::class)) {
                throw new \Exception('The controller method must return a view instance.');
            }

            // Set the page view.
            $this->ui()->setViewInstance($response);
        }
    }
615145
public Route matchRoute(String url) {
        if (hashRoute.containsKey(url)) {
            return new Route(hashRoute.get(url).get(0), null);
        }

        for (RegexRoute route : regexRoute) {
            Matcher matcher = route.getPattern().matcher(url);
            if (matcher.matches()) {
                return new Route(route, matcher);
            }
        }
        return null;
    }
500755
public static function Route($route, $controller, $closure = null) {
        $route = strtolower($route);
        $controller = ucwords(strtolower($controller));
        $request = KernelHttp::request();
        if($request->getUrlApi() == $route)
            self::explorer($route, $controller, $closure, $request);
    }
905548
private function parseRouteConfiguration($route)
    {
        if (!is_array($route)) {
            throw new Exception("Strata configuration file contains an invalid route.");
        }

        return $this->isDynamic($route) ?
            $this->parseDynamicRoute($route) :
            $this->parseMatchedRoute($route);
    }
167295
public static List<RouteHeader> getRouteList(Response response, HeaderFactory headerFactory) throws ParseException {
		// we have record route set, as we are client, this is reversed
		final ArrayList<RouteHeader> routeList = new ArrayList<RouteHeader>();
		final ListIterator<?> rrLit = response.getHeaders(RecordRouteHeader.NAME);
		while (rrLit.hasNext()) {
			final RecordRouteHeader rrh = (RecordRouteHeader) rrLit.next();
			final RouteHeader rh = headerFactory.createRouteHeader(rrh.getAddress());
			final Iterator<?> pIt = rrh.getParameterNames();
			while (pIt.hasNext()) {
				final String pName = (String) pIt.next();
				rh.setParameter(pName, rrh.getParameter(pName));
			}
			routeList.add(0, rh);
		}
		return routeList;
	}
1096724
public function parse()
    {
        preg_match_all("#\{(\w+)\}#", $this->uri, $params);
        $replace = [];

        foreach ($params[1] as $param) {
            $replace['{'.$param.'}'] = '(?<'.$param.'>'. (isset($this->filters[$param]) ? $this->filters[$param] : '[a-zA-Z+0-9-.]+') .')';
        }

        $this->parsedRoute = str_replace(array_keys($replace), array_values($replace), $this->uri);
    }
1364409
public function handle(ParsedRoute $route)
    {
        $controller = $route->controller();
        $rawParams = $route->params();
        foreach ($rawParams as $param => $value) {
            if (strpos($controller, "{".$param."}") !== false) {
                $controller = str_replace("{".$param."}", ucfirst($value), $controller);
                unset($rawParams[$param]);
            }
        }
        $segments = explode("::", $controller);
        $controller = $segments[0];
        $action = count($segments) > 1 ? $segments[1] : "index";
        if (method_exists($controller, $action)) {
            $params = [$rawParams];
            return call_user_func_array([new $controller, $action], $params);
        }

        throw new RuntimeException("No method {$action} in controller {$segments[0]}");
    }