public static function fullUrl($url, $domain = null)
    {
        if (!preg_match('/^https?:\/\//i', $url)) {
            // Fix for root page link
            if ($url === '/') {
                $url = '';
            }

            // remove first /
            if (strpos($url, '/') === 0) {
                $url = substr($url, 1);
            }

            if ($domain !== null) {
                // specified domain
                $url = 'http://' . $domain . '/' . $url;
            } else {
                // domain from env
                $url = Typo3GeneralUtility::getIndpEnv('TYPO3_SITE_URL') . $url;
            }
        }

        // Fix url stuff
        $url = str_replace('?&', '?', $url);

        return $url;
    }