fix switching to username containing special characters

Escape username with encodeURIComponent. It fixes usernames with '+' character etc.