URI will do the right thing if you give it a URI object. You could replace this with just ```url = URI(url)```