mirror of https://github.com/kiwix/libkiwix.git
Simpler fullURL2LocalURL()
This commit is contained in:
parent
71a66e0528
commit
2c5e84b6b3
|
@ -95,16 +95,10 @@ inline std::string normalizeRootUrl(std::string rootUrl)
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string
|
std::string
|
||||||
fullURL2LocalURL(const std::string& full_url, const std::string& rootLocation)
|
fullURL2LocalURL(const std::string& fullUrl, const std::string& rootLocation)
|
||||||
{
|
{
|
||||||
if (rootLocation.empty()) {
|
if ( kiwix::startsWith(fullUrl, rootLocation + "/") ) {
|
||||||
// nothing special to handle.
|
return fullUrl.substr(rootLocation.size());
|
||||||
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());
|
|
||||||
} else {
|
} else {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue