Paginate_links links not working accordingly to how I do query the page

Ok, the issue seems to be connected with the base and format parameters. I may not able to explain properly technically what has happened.
However, from what I see in my archive page, my page parameter is by default “page” and not “paged” as expected.

That said, when using the base parameter set to ‘%#%’ the hash is supposed to take the correct previous or next page number. This make impossible to use the format and tweak the output if required.

On the contrary, using the ‘%_%’ that force WP to use the format parameter setting the ‘%#%’ as part of the value gets WP to always use the current page everywhere.

So the solution I found was to tweak everything in the base parameter like in the following snippet:

$paginate_links = paginate_links( array(
                'base' => preg_replace('/\?.*/', "https://wordpress.stackexchange.com/", get_pagenum_link()) . '%_%',
                'prev_text' => __('« Indietro'),
                'next_text' => __('Avanti »'),
                'mid_size'  => 5,
                'current'   => $current,
                'total'     => $totalpages
            ));