I run a couple of times into situations where I need to change the URI a little bit. It ends up as a mess of if/else-s because the urls can have different protocols, may or may not contain a user and port, may have params, etc.
I propose a function `construct_uri(protocol, user, domain, port, params)` which returns a URI based on those arguments. The user, port, params parts should be optional, so it should be legal to call:
construct_uri("sip", null, "184.108.40.206", null, null) -> "sip:220.127.116.11"
construct_uri("sip", $rU, $rd, null, "key=val") -> "sip:$rU@$rd;key=val" (with expanded vars of course)