Gamma-ray bursts as sources of ultra-high energy cosmic rays across the ankle