Preparing to save a few CPU cycles

This commit is contained in:
Veloman Yunkan 2023-02-08 21:16:10 +01:00
parent 2c5e84b6b3
commit a7fe4193e3
1 changed files with 4 additions and 3 deletions

View File

@ -97,8 +97,9 @@ inline std::string normalizeRootUrl(std::string rootUrl)
std::string
fullURL2LocalURL(const std::string& fullUrl, const std::string& rootLocation)
{
if ( kiwix::startsWith(fullUrl, rootLocation + "/") ) {
return fullUrl.substr(rootLocation.size());
assert(rootLocation.size() > 0 && rootLocation.back() == '/');
if ( kiwix::startsWith(fullUrl, rootLocation) ) {
return fullUrl.substr(rootLocation.size() - 1);
} else {
return "";
}
@ -518,7 +519,7 @@ MHD_Result InternalServer::handlerCallback(struct MHD_Connection* connection,
printf("full_url : %s\n", fullUrl);
}
const auto url = fullURL2LocalURL(fullUrl, m_root);
const auto url = fullURL2LocalURL(fullUrl, m_root + "/");
RequestContext request(connection, m_root, url, method, version);
if (m_verbose.load() ) {