summaryrefslogtreecommitdiff
path: root/src/storage
diff options
context:
space:
mode:
authorMax Kellermann <max@musicpd.org>2020-03-13 18:15:21 +0100
committerMax Kellermann <max@musicpd.org>2020-03-13 18:54:41 +0100
commit332f480ec3f9e6fb3f0e9e2efb58dfe0deecf9b0 (patch)
treefda168f301658ac2f9d0582896bba69eeeb3ac74 /src/storage
parent9a164668f246b8bbb88d2f9f6412834fac9dcfa5 (diff)
util/UriExtract: uri_get_path() returns std::string_view
Diffstat (limited to 'src/storage')
-rw-r--r--src/storage/plugins/CurlStorage.cxx16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/storage/plugins/CurlStorage.cxx b/src/storage/plugins/CurlStorage.cxx
index 07f25c441..98f6de247 100644
--- a/src/storage/plugins/CurlStorage.cxx
+++ b/src/storage/plugins/CurlStorage.cxx
@@ -456,11 +456,11 @@ CurlStorage::GetInfo(const char *uri_utf8, gcc_unused bool follow)
}
gcc_pure
-static const char *
+static std::string_view
UriPathOrSlash(const char *uri) noexcept
{
- const char *path = uri_get_path(uri);
- if (path == nullptr)
+ auto path = uri_get_path(uri);
+ if (path.data() == nullptr)
path = "/";
return path;
}
@@ -495,7 +495,7 @@ private:
*/
gcc_pure
StringView HrefToEscapedName(const char *href) const noexcept {
- const char *path = uri_get_path(href);
+ StringView path = uri_get_path(href);
if (path == nullptr)
return nullptr;
@@ -504,16 +504,16 @@ private:
case in hex digits in escaped characters; TODO:
implement properly */
path = StringAfterPrefixIgnoreCase(path, base_path.c_str());
- if (path == nullptr || *path == 0)
+ if (path == nullptr || path.empty())
return nullptr;
- const char *slash = strchr(path, '/');
+ const char *slash = path.Find('/');
if (slash == nullptr)
/* regular file */
return path;
- else if (slash[1] == 0)
+ else if (slash == &path.back())
/* trailing slash: collection; strip the slash */
- return {path, slash};
+ return {path.data, slash};
else
/* strange, better ignore it */
return nullptr;