Clean up URLs into nested patterns