From b83392cb044b6c6d3cb32df3d2a121b29334f609 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Fri, 6 Nov 2015 09:43:37 +0100 Subject: util/UriUtil: move code to SkipUriScheme() --- src/util/UriUtil.cxx | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) (limited to 'src/util') diff --git a/src/util/UriUtil.cxx b/src/util/UriUtil.cxx index 3f5ae3118..44b3e53ab 100644 --- a/src/util/UriUtil.cxx +++ b/src/util/UriUtil.cxx @@ -104,17 +104,26 @@ uri_safe_local(const char *uri) } } -std::string -uri_remove_auth(const char *uri) +gcc_pure +static const char * +SkipUriScheme(const char *uri) { - const char *auth; if (memcmp(uri, "http://", 7) == 0) - auth = uri + 7; + return uri + 7; else if (memcmp(uri, "https://", 8) == 0) - auth = uri + 8; + return uri + 8; else if (memcmp(uri, "ftp://", 6) == 0) - auth = uri + 6; + return uri + 6; else + /* 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(); -- cgit v1.2.3