Cleanup after previous change

- Got rid of the continue statement
- Renamed the function parameter
- Fixed indentation
This commit is contained in:
Veloman Yunkan 2024-03-04 17:33:21 +04:00 committed by Matthieu Gautier
parent 5b9daf0d9d
commit 181893d31a
1 changed files with 14 additions and 16 deletions

View File

@ -35,26 +35,24 @@ HumanReadableNameMapper::HumanReadableNameMapper(kiwix::Library& library, bool w
continue;
auto aliasName = replaceRegex(bookName, "", "_[[:digit:]]{4}-[[:digit:]]{2}$");
if (aliasName == bookName) {
continue;
if (aliasName != bookName) {
mapName(library, aliasName, bookId);
}
mapName(library, aliasName, bookId);
}
}
void HumanReadableNameMapper::mapName(const Library& library, std::string aliasName, std::string bookId) {
if (m_nameToId.find(aliasName) == m_nameToId.end()) {
m_nameToId[aliasName] = bookId;
} else {
const auto& currentBook = library.getBookById(bookId);
auto alreadyPresentPath = library.getBookById(m_nameToId[aliasName]).getPath();
std::cerr << "Path collision: " << alreadyPresentPath
<< " and " << currentBook.getPath()
<< " can't share the same URL path '" << aliasName << "'."
<< " Therefore, only " << alreadyPresentPath
<< " will be served." << std::endl;
}
void HumanReadableNameMapper::mapName(const Library& library, std::string name, std::string bookId) {
if (m_nameToId.find(name) == m_nameToId.end()) {
m_nameToId[name] = bookId;
} else {
const auto& currentBook = library.getBookById(bookId);
auto alreadyPresentPath = library.getBookById(m_nameToId[name]).getPath();
std::cerr << "Path collision: " << alreadyPresentPath
<< " and " << currentBook.getPath()
<< " can't share the same URL path '" << name << "'."
<< " Therefore, only " << alreadyPresentPath
<< " will be served." << std::endl;
}
}
std::string HumanReadableNameMapper::getNameForId(const std::string& id) const {