From 0564c8006da7077064222d15a899b858ae2d7e61 Mon Sep 17 00:00:00 2001 From: Marvin Borner Date: Tue, 24 Nov 2020 14:03:14 +0100 Subject: Added port support in URLs --- apps/browser.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'apps') diff --git a/apps/browser.c b/apps/browser.c index 157ddbd..83292e9 100644 --- a/apps/browser.c +++ b/apps/browser.c @@ -132,6 +132,14 @@ void on_submit(void *event, struct element *box) (void)event; char *url = ((struct element_text_input *)box->data)->text; + u16 port = 80; + char *port_str = strchr(url, ':'); + if (port_str) { + port_str[0] = '\0'; + port_str++; + port = atoi(port_str); + } + char *path = strchr(url, '/'); if (path) { path[0] = '\0'; @@ -148,7 +156,7 @@ void on_submit(void *event, struct element *box) struct element_label *c = code_label->data; struct socket *socket = net_open(S_TCP); - if (socket && net_connect(socket, ip, 80, NET_TIMEOUT)) { + if (socket && net_connect(socket, ip, port, NET_TIMEOUT)) { net_send(socket, query, strlen(query)); char buf[4096] = { 0 }; char parsed[4096] = { 0 }; -- cgit v1.2.3