From 7d3ef3a6c98c79e6b5e681445399714926c8fdd1 Mon Sep 17 00:00:00 2001 From: Rockingcool Date: Wed, 8 Mar 2023 23:27:46 -0600 Subject: [PATCH] Added helper library for URL manipulation functions --- url_manipulation.c | 37 +++++++++++++++++++++++++++++++++++++ url_manipulation.h | 12 ++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 url_manipulation.c create mode 100644 url_manipulation.h diff --git a/url_manipulation.c b/url_manipulation.c new file mode 100644 index 0000000..28a517b --- /dev/null +++ b/url_manipulation.c @@ -0,0 +1,37 @@ +#include +#include + +char* url_to_proto(char* url) { + size_t length = strlen(url); + int sentinel = 0; + char* to_return = malloc(sizeof(char) * 10); + for (int i=0;i + +/* url_to_proto - This takes in a URL, and returns the protocol. +Example - 'https://example.org' would return 'https'. */ + +char* url_to_proto(char* url); + +/* url_to_hostname - This takes in a URL, and returns the hostname. +Example - 'https://example.org' would return 'example.org'. */ + +char* url_to_hostname(char* url); +