Refactor URL formatting code into its own module.