public function getRouteFromPathInfo(Request $request) {

		$application = Application::getInstance();
		$script = basename($request->getScriptName());

		if(!($path = trim($request->getPathInfo(), '/'))) {
			$pathSegments = [];
		}
		else {
			$pathSegments = explode('/' , $path);
		}

		// skip if pathinfo matches script name

		if(count($pathSegments) && $this->serverSideRewrite && basename($script, '.php') === $pathSegments[0]) {
			array_shift($pathSegments);
		}

		// when locale is found, set it as current locale in application and skip it

		if(count($pathSegments) && $application->hasLocale($pathSegments[0])) {
			$application->setCurrentLocale($application->getLocale($pathSegments[0]));
			array_shift($pathSegments);
		}

		// find route

        $route = $this->findRoute($pathSegments);

		// no route found

        if(!$route) {
            throw new ApplicationException(sprintf("No route found for path '%s'.", implode('/', $pathSegments)));
        }

		while(!$this->authenticateRoute($route)) {
            $route = $this->authenticator->handleViolation($route);
        }

		return $route;

	}