diff options
author | Max Kellermann <max@duempel.org> | 2015-11-06 09:47:28 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2015-11-06 09:49:22 +0100 |
commit | 75d46efd235b2848f77a2d92013d3b4722a0dbeb (patch) | |
tree | 01c17d20e8c489ce9bee23a22ddaa52865604636 | |
parent | b83392cb044b6c6d3cb32df3d2a121b29334f609 (diff) | |
download | mpd-75d46efd235b2848f77a2d92013d3b4722a0dbeb.tar.gz mpd-75d46efd235b2848f77a2d92013d3b4722a0dbeb.tar.xz mpd-75d46efd235b2848f77a2d92013d3b4722a0dbeb.zip |
util/UriUtil: use StringAfterPrefix() instead of memcmp()
-rw-r--r-- | src/util/UriUtil.cxx | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/src/util/UriUtil.cxx b/src/util/UriUtil.cxx index 44b3e53ab..f9dba97af 100644 --- a/src/util/UriUtil.cxx +++ b/src/util/UriUtil.cxx @@ -18,6 +18,7 @@ */ #include "UriUtil.hxx" +#include "StringCompare.hxx" #include <assert.h> #include <string.h> @@ -108,15 +109,14 @@ gcc_pure static const char * SkipUriScheme(const char *uri) { - if (memcmp(uri, "http://", 7) == 0) - return uri + 7; - else if (memcmp(uri, "https://", 8) == 0) - return uri + 8; - else if (memcmp(uri, "ftp://", 6) == 0) - return uri + 6; - else - /* unrecognized URI */ - return nullptr; + const char *const schemes[] = { "http://", "https://", "ftp://" }; + for (auto scheme : schemes) { + auto result = StringAfterPrefix(uri, scheme); + if (result != nullptr) + return result; + } + + return nullptr; } std::string |