protected function addQueryString(string $uri, array $parameters): string
    {
        // If the URI has a fragment we will move it to the end of this URI since it will
        // need to come after any query string that may be added to the URL else it is
        // not going to be available. We will remove it then append it back on here.
        if (null !== ($fragment = \parse_url($uri, \PHP_URL_FRAGMENT))) {
            $uri = \preg_replace('/#.*/', '', $uri);
        }

        $uri .= $this->getRouteQueryString($parameters);

        if (null === $fragment) {
            return $uri;
        }

        return $uri . '#' . \strtr(\rawurlencode($fragment), ['%2F' => '/', '%3F' => '?']);
    }