Simpler fullURL2LocalURL()

This commit is contained in:
Veloman Yunkan 2023-02-08 21:12:49 +01:00
parent 71a66e0528
commit 2c5e84b6b3
1 changed files with 3 additions and 9 deletions

View File

@ -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 "";
}