From a7fe4193e3f693a0057d5081ba82193525b47640 Mon Sep 17 00:00:00 2001 From: Veloman Yunkan Date: Wed, 8 Feb 2023 21:16:10 +0100 Subject: [PATCH] Preparing to save a few CPU cycles --- src/server/internalServer.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/server/internalServer.cpp b/src/server/internalServer.cpp index 098cb6ac4..1536e86e6 100644 --- a/src/server/internalServer.cpp +++ b/src/server/internalServer.cpp @@ -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() ) {