Extract out url builder

@malcyl - Got what we were working on earlier with the splitting out of the URL sorted. Was more hassle than you'd expect!