util/UriUtil: use StringAfterPrefix() instead of memcmp()
This commit is contained in:
parent
b83392cb04
commit
75d46efd23
@ -18,6 +18,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "UriUtil.hxx"
|
#include "UriUtil.hxx"
|
||||||
|
#include "StringCompare.hxx"
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@ -108,15 +109,14 @@ gcc_pure
|
|||||||
static const char *
|
static const char *
|
||||||
SkipUriScheme(const char *uri)
|
SkipUriScheme(const char *uri)
|
||||||
{
|
{
|
||||||
if (memcmp(uri, "http://", 7) == 0)
|
const char *const schemes[] = { "http://", "https://", "ftp://" };
|
||||||
return uri + 7;
|
for (auto scheme : schemes) {
|
||||||
else if (memcmp(uri, "https://", 8) == 0)
|
auto result = StringAfterPrefix(uri, scheme);
|
||||||
return uri + 8;
|
if (result != nullptr)
|
||||||
else if (memcmp(uri, "ftp://", 6) == 0)
|
return result;
|
||||||
return uri + 6;
|
}
|
||||||
else
|
|
||||||
/* unrecognized URI */
|
return nullptr;
|
||||||
return nullptr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string
|
std::string
|
||||||
|
Loading…
Reference in New Issue
Block a user