diff options
author | Max Kellermann <max@duempel.org> | 2015-11-06 09:43:37 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2015-11-06 09:49:22 +0100 |
commit | b83392cb044b6c6d3cb32df3d2a121b29334f609 (patch) | |
tree | e05ca68b503a8345787eed9d587d6cd519c8b4aa /src | |
parent | 7640d333f48e4a782e3ea62ac686902ddf155592 (diff) | |
download | mpd-b83392cb044b6c6d3cb32df3d2a121b29334f609.tar.gz mpd-b83392cb044b6c6d3cb32df3d2a121b29334f609.tar.xz mpd-b83392cb044b6c6d3cb32df3d2a121b29334f609.zip |
util/UriUtil: move code to SkipUriScheme()
Diffstat (limited to 'src')
-rw-r--r-- | src/util/UriUtil.cxx | 21 |
1 files changed, 15 insertions, 6 deletions
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,18 +104,27 @@ 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(); const char *slash = strchr(auth, '/'); |