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, "126.96.36.199", null, null) -> "sip:188.8.131.52"
construct_uri("sip", $rU, $rd, null, "key=val") -> "sip:$rU@$rd;key=val" (with expanded vars of course)