Ensure url encoding for invalid urls