diff options
author | Max Kellermann <max@duempel.org> | 2014-11-01 12:45:47 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2014-11-02 11:53:31 +0100 |
commit | 674091424e715fddd8fbfe8146f351da5bf84974 (patch) | |
tree | bdbcf6f8d7276fa278baf1750e27992f679a2474 /src/util/UriUtil.cxx | |
parent | 6ad336743d861a03df3079058fdc18eee07a3014 (diff) | |
download | mpd-674091424e715fddd8fbfe8146f351da5bf84974.tar.gz mpd-674091424e715fddd8fbfe8146f351da5bf84974.tar.xz mpd-674091424e715fddd8fbfe8146f351da5bf84974.zip |
util/UriUtil: add uri_get_suffix() overload that ignores query string
Diffstat (limited to 'src/util/UriUtil.cxx')
-rw-r--r-- | src/util/UriUtil.cxx | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/util/UriUtil.cxx b/src/util/UriUtil.cxx index 2609db2cf..1783fbca5 100644 --- a/src/util/UriUtil.cxx +++ b/src/util/UriUtil.cxx @@ -44,6 +44,23 @@ uri_get_suffix(const char *uri) return suffix; } +const char * +uri_get_suffix(const char *uri, UriSuffixBuffer &buffer) +{ + const char *suffix = uri_get_suffix(uri); + if (suffix == nullptr) + return nullptr; + + const char *q = strchr(suffix, '?'); + if (q != nullptr && size_t(q - suffix) < sizeof(buffer.data)) { + memcpy(buffer.data, suffix, q - suffix); + buffer.data[q - suffix] = 0; + suffix = buffer.data; + } + + return suffix; +} + static const char * verify_uri_segment(const char *p) { |