extractSipUsername
Static utility method that extracts the username portion from the call.to
field of a parsed request body. Handles three input formats:
sip:username@domain(orsips:...) — strips the scheme and@domainsuffix, returning the usernametel:+1234567890— strips thetel:scheme, returning the phone number- Plain string — returned as-is
Commonly paired with
registerRoutingCallback() to route SIP traffic
based on the dialed user.
Parameters
requestBody
The parsed JSON body from an incoming request. Expected to contain a
call.to field with a SIP URI, TEL URI, or phone number string.
Returns
string | null — The extracted username or phone number, or null if the
call.to field is missing or cannot be parsed.