Referer check in the location state change handler