public static function replaceFragment($uri, $newFragment = '')
    {
        if ($uri === null) {
            $uri = static::getCurrentRequestUri();
        }
        $oldFragment = parse_url($uri, PHP_URL_FRAGMENT);
        return $oldFragment
            ? str_replace('#' . $oldFragment, '#' . $newFragment, $uri)
            : ($newFragment ? $uri . '#' . $newFragment : $uri);
    }