Changed encoding method to encodeURIComponent