UriUtil: add function uri_get_scheme()

Replaces g_uri_parse_scheme().
This commit is contained in:
Max Kellermann
2013-12-15 17:05:18 +01:00
parent 65b8e52d80
commit e1ec65bd53
3 changed files with 20 additions and 7 deletions

View File

@@ -27,6 +27,16 @@ bool uri_has_scheme(const char *uri)
return strstr(uri, "://") != nullptr;
}
std::string
uri_get_scheme(const char *uri)
{
const char *end = strstr(uri, "://");
if (end == nullptr)
end = uri;
return std::string(uri, end);
}
/* suffixes should be ascii only characters */
const char *
uri_get_suffix(const char *uri)

View File

@@ -31,6 +31,13 @@
gcc_pure
bool uri_has_scheme(const char *uri);
/**
* Returns the scheme name of the specified URI, or an empty string.
*/
gcc_pure
std::string
uri_get_scheme(const char *uri);
gcc_pure
const char *
uri_get_suffix(const char *uri);