private function filterQuery(string $query): string
    {
        if (trim($query) == '') {
            return '';
        }

        if ($query[0] == '?') {
            $query = substr($query, 1);
        }

        $parts = explode('&', $query);
        foreach ($parts as $index => $part) {
            $data = explode('=', $part);
            $key = array_shift($data);

            if (count($data) == 0) {
                $parts[$index] = $this->encodeQuery($key);
                continue;
            }

            $value = implode('=', $data);
            $parts[$index] = $this->encodeQuery($key).'='.$this->encodeQuery($value);
        }

        return implode('&', $parts);
    }