Logic for short URLs