Using URI.parse to get port address

URI.parse will work out the port number rather than splitting :+1: 

This will then allow you to use uri.host and uri.port.