diff options
author | Max Kellermann <max@duempel.org> | 2014-11-01 12:45:47 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2014-11-01 12:45:47 +0100 |
commit | eab32f2e5d8114d08e392001f0004284267bebd5 (patch) | |
tree | 664d97672c8fc17d659064aef201030540d1625e /src/util/UriUtil.cxx | |
parent | d42c0f1dc5063d50a62817b63a1c2a4507c46071 (diff) |
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 fdca47c00..62977e91b 100644 --- a/src/util/UriUtil.cxx +++ b/src/util/UriUtil.cxx @@ -54,6 +54,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) { |