Commit b83392cb authored by Max Kellermann's avatar Max Kellermann

util/UriUtil: move code to SkipUriScheme()

parent 7640d333
...@@ -104,18 +104,27 @@ uri_safe_local(const char *uri) ...@@ -104,18 +104,27 @@ uri_safe_local(const char *uri)
} }
} }
std::string gcc_pure
uri_remove_auth(const char *uri) static const char *
SkipUriScheme(const char *uri)
{ {
const char *auth;
if (memcmp(uri, "http://", 7) == 0) if (memcmp(uri, "http://", 7) == 0)
auth = uri + 7; return uri + 7;
else if (memcmp(uri, "https://", 8) == 0) else if (memcmp(uri, "https://", 8) == 0)
auth = uri + 8; return uri + 8;
else if (memcmp(uri, "ftp://", 6) == 0) else if (memcmp(uri, "ftp://", 6) == 0)
auth = uri + 6; return uri + 6;
else else
/* unrecognized URI */ /* unrecognized URI */
return nullptr;
}
std::string
uri_remove_auth(const char *uri)
{
const char *auth = SkipUriScheme(uri);
if (auth == nullptr)
/* unrecognized URI */
return std::string(); return std::string();
const char *slash = strchr(auth, '/'); const char *slash = strchr(auth, '/');
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment