Harden URL parsing