diff --git a/src/util/UriExtract.cxx b/src/util/UriExtract.cxx index b6b51a7d0..4e45040ce 100644 --- a/src/util/UriExtract.cxx +++ b/src/util/UriExtract.cxx @@ -82,17 +82,17 @@ uri_after_scheme(const char *uri) noexcept bool uri_has_scheme(const char *uri) noexcept { - return !uri_get_scheme(uri).IsNull(); + return !uri_get_scheme(uri).empty(); } -StringView -uri_get_scheme(const char *uri) noexcept +std::string_view +uri_get_scheme(std::string_view uri) noexcept { - const char *end = strstr(uri, "://"); - if (end == nullptr) - return nullptr; + auto end = uri.find("://"); + if (end == std::string_view::npos) + return {}; - return {uri, end}; + return uri.substr(0, end); } bool diff --git a/src/util/UriExtract.hxx b/src/util/UriExtract.hxx index 1d96e6fc8..a47cf2cd0 100644 --- a/src/util/UriExtract.hxx +++ b/src/util/UriExtract.hxx @@ -32,7 +32,7 @@ #include "Compiler.h" -struct StringView; +#include /** * Checks whether the specified URI has a scheme in the form @@ -46,8 +46,8 @@ uri_has_scheme(const char *uri) noexcept; * Returns the scheme name of the specified URI, or an empty string. */ gcc_pure -StringView -uri_get_scheme(const char *uri) noexcept; +std::string_view +uri_get_scheme(std::string_view uri) noexcept; gcc_pure bool