Ensure that the root is correctly formatted.

This commit is contained in:
Matthieu Gautier 2019-08-10 13:59:40 +02:00
parent c890e1c87e
commit e452f5cf36
2 changed files with 12 additions and 1 deletions

View File

@ -50,7 +50,7 @@ namespace kiwix
*/
void stop();
void set_root(const std::string& root) { m_root = root; }
void set_root(const std::string& root);
void set_addr(const std::string& addr) { m_addr = addr; }
void set_port(int port) { m_port = port; }
void set_nbThreads(int threads) { m_nbThreads = threads; }

View File

@ -172,6 +172,17 @@ void Server::stop() {
mp_server.reset(nullptr);
}
void Server::set_root(const std::string& root)
{
m_root = root;
if (m_root[0] != '/') {
m_root = "/" + m_root;
}
if (m_root.back() == '/') {
m_root.erase(m_root.size() - 1);
}
}
InternalServer::InternalServer(Library& library,
NameMapper* nameMapper,