mirror of
https://github.com/Team-Resurgent/BearSSL-OG.git
synced 2026-08-15 11:18:20 -07:00
26 lines
632 B
C++
26 lines
632 B
C++
#include "url_utility.h"
|
|
#include "pointer_vector.h"
|
|
#include "string_utility.h"
|
|
|
|
bool url_utility::parse_url(const char* url, char** host, char** path)
|
|
{
|
|
bool result = false;
|
|
|
|
pointer_vector<char*>* url_parts = string_utility::split_first(url, "://", true);
|
|
if (url_parts->count() == 2)
|
|
{
|
|
pointer_vector<char*>* domain_parts = string_utility::split_first(url_parts->get(1), "/", true);
|
|
if (domain_parts->count() == 2)
|
|
{
|
|
*host = strdup(domain_parts->get(0));
|
|
*path = string_utility::format_string("/%s", domain_parts->get(1));
|
|
result = true;
|
|
}
|
|
delete(domain_parts);
|
|
}
|
|
delete(url_parts);
|
|
|
|
return result;
|
|
}
|
|
|