Normalize printed rootLocation

Reusing libkiwix's normalizeRootUrl() to display a more reliable representation of the
rootLocation the InternalServer will be using.

Can't reuse server.m_root as it is private.
pull/571/head
renaud gaudin 4 years ago
parent 9c16e53767
commit 442de30ff7

@ -103,6 +103,16 @@ std::string loadCustomTemplate (std::string customIndexPath) {
return indexTemplateString;
}
inline std::string normalizeRootUrl(std::string rootUrl)
{
while ( !rootUrl.empty() && rootUrl.back() == '/' )
rootUrl.pop_back();
while ( !rootUrl.empty() && rootUrl.front() == '/' )
rootUrl = rootUrl.substr(1);
return rootUrl.empty() ? rootUrl : "/" + rootUrl;
}
volatile sig_atomic_t waiting = false;
volatile sig_atomic_t libraryMustBeReloaded = false;
@ -393,7 +403,7 @@ int main(int argc, char** argv)
exit(1);
}
std::string url = "http://" + server.getAddress() + ":" + std::to_string(server.getPort()) + rootLocation;
std::string url = "http://" + server.getAddress() + ":" + std::to_string(server.getPort()) + normalizeRootUrl(rootLocation);
std::cout << "The Kiwix server is running and can be accessed in the local network at: "
<< url << std::endl;

Loading…
Cancel
Save