JS debugging: fix broken script refs caused by redirection