From 2c5e84b6b3ea30e30b8d708a862ea47b43a5c46b Mon Sep 17 00:00:00 2001 From: Veloman Yunkan Date: Wed, 8 Feb 2023 21:12:49 +0100 Subject: [PATCH] Simpler fullURL2LocalURL() --- src/server/internalServer.cpp | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/src/server/internalServer.cpp b/src/server/internalServer.cpp index a9d809e3..098cb6ac 100644 --- a/src/server/internalServer.cpp +++ b/src/server/internalServer.cpp @@ -95,16 +95,10 @@ inline std::string normalizeRootUrl(std::string rootUrl) } std::string -fullURL2LocalURL(const std::string& full_url, const std::string& rootLocation) +fullURL2LocalURL(const std::string& fullUrl, const std::string& rootLocation) { - if (rootLocation.empty()) { - // nothing special to handle. - return full_url; - } else if (full_url == rootLocation) { - return "/"; - } else if (full_url.size() > rootLocation.size() && - full_url.substr(0, rootLocation.size()+1) == rootLocation + "/") { - return full_url.substr(rootLocation.size()); + if ( kiwix::startsWith(fullUrl, rootLocation + "/") ) { + return fullUrl.substr(rootLocation.size()); } else { return ""; }