Can't call back() on an empty string. Causes unittest_rgw_kms
to fail when compiled with _GLIBCXX_ASSERTIONS.
Signed-off-by: Samuel Just <sjust@redhat.com>
* empty, the URL is not changed.
*/
static void concat_url(std::string &url, std::string path) {
+ bool url_has_slash = !url.empty() && url.back() == '/';
if (!path.empty()) {
- if (url.back() == '/' && path.front() == '/') {
+ if (url_has_slash && path.front() == '/') {
url.pop_back();
- } else if (url.back() != '/' && path.front() != '/') {
+ } else if (!url_has_slash && path.front() != '/') {
url.push_back('/');
}
url.append(path);