public function getSiteUrl(Environment $environment, $appName, EnvironmentDeployment $deployment = null)
    {
        $deployment = $deployment ?: $this->getCurrentDeployment($environment);
        $routes = $deployment->routes;
        $appUrls = [];
        foreach ($routes as $url => $route) {
            if ($route->type === 'upstream' && $route->__get('upstream') === $appName) {
                $appUrls[] = $url;
            }
        }
        usort($appUrls, [$this, 'urlSort']);
        $siteUrl = reset($appUrls);
        if ($siteUrl) {
            return $siteUrl;
        }
        if ($environment->hasLink('public-url')) {
            return $environment->getLink('public-url');
        }

        return null;
    }