From bab626c32514131597aad229d755b7a2491b0309 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Wed, 4 Nov 2020 21:14:34 +0100 Subject: [PATCH] util/UriExtract: remove the query string at the beginning of uri_get_suffix() --- src/util/UriExtract.cxx | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/util/UriExtract.cxx b/src/util/UriExtract.cxx index fd09e699d..a5bb815c8 100644 --- a/src/util/UriExtract.cxx +++ b/src/util/UriExtract.cxx @@ -120,11 +120,19 @@ uri_get_path(std::string_view uri) noexcept return uri; } +gcc_pure +static StringView +UriWithoutQueryString(StringView uri) noexcept +{ + return uri.Split('?').first; +} + /* suffixes should be ascii only characters */ std::string_view uri_get_suffix(std::string_view _uri) noexcept { - StringView uri(_uri); + const auto uri = UriWithoutQueryString(_uri); + const char *dot = uri.FindLast('.'); if (dot == nullptr || dot == uri.data || dot[-1] == '/' || dot[-1] == '\\') @@ -135,8 +143,7 @@ uri_get_suffix(std::string_view _uri) noexcept /* this was not the last path segment */ return {}; - /* remove the query string */ - return suffix.Split('?').first; + return suffix; } const char *