When Basic auth is configured the URL isn't changed.

When Basic auth was configured, it used to forget to copy the query and fragment parts of the URL. This fix copies the entire URL when adding the username and password.

Fixes #388