Fix redirects in javascript