fix getRedirectScript function