mirror of
https://github.com/profanity-im/profanity.git
synced 2024-10-27 20:30:13 -04:00
simplify some code
Signed-off-by: Steffen Jaeckel <jaeckel-floss@eyet-services.de>
This commit is contained in:
parent
92eed34fb3
commit
e99c4b7128
@ -863,12 +863,8 @@ _split_url(const char* alturi, gchar** host, gint* port)
|
|||||||
/* Construct a valid URI with `schema://` as `g_uri_split_network()`
|
/* Construct a valid URI with `schema://` as `g_uri_split_network()`
|
||||||
* requires this to be there.
|
* requires this to be there.
|
||||||
*/
|
*/
|
||||||
const char* xmpp = "xmpp://";
|
auto_gchar gchar* xmpp_uri = g_strdup_printf("xmpp://%s", alturi);
|
||||||
char* xmpp_uri = _xmalloc(strlen(xmpp) + strlen(alturi) + 1, NULL);
|
|
||||||
memcpy(xmpp_uri, xmpp, strlen(xmpp));
|
|
||||||
memcpy(xmpp_uri + strlen(xmpp), alturi, strlen(alturi) + 1);
|
|
||||||
gboolean ret = g_uri_split_network(xmpp_uri, 0, NULL, host, port, NULL);
|
gboolean ret = g_uri_split_network(xmpp_uri, 0, NULL, host, port, NULL);
|
||||||
free(xmpp_uri);
|
|
||||||
/* fix-up `port` as g_uri_split_network() sets port to `-1` if it's missing
|
/* fix-up `port` as g_uri_split_network() sets port to `-1` if it's missing
|
||||||
* in the passed-in URI, but libstrophe expects a "missing port"
|
* in the passed-in URI, but libstrophe expects a "missing port"
|
||||||
* to be passed as `0` (which then results in connecting to the standard port).
|
* to be passed as `0` (which then results in connecting to the standard port).
|
||||||
|
Loading…
Reference in New Issue
Block a user