diff --git a/lib/src/HostRedirector.cc b/lib/src/HostRedirector.cc index b1a9398647..57486080e5 100644 --- a/lib/src/HostRedirector.cc +++ b/lib/src/HostRedirector.cc @@ -129,12 +129,11 @@ void HostRedirector::lookup(string &host, string &path) const if (isWildcard) { const string &toPath = to->path; - const auto len = path.size(); - auto start = len - lastWildcardPathViewLen; - start += toPath.back() == '/' && path[start] == '/'; - - path.reserve(toPath.size() + (len - start)); - path.replace(0, start, toPath); + const auto start = path.size() - lastWildcardPathViewLen; + path.replace(0, + start + + (toPath.back() == '/' && path[start] == '/'), + toPath); } else path = to->path;