mirror of https://github.com/kiwix/libkiwix.git
Refactoring: extracted get_book_name()
This commit is contained in:
parent
2d3bf9b981
commit
bbc06931ad
|
@ -831,6 +831,20 @@ Response InternalServer::handle_catalog(const RequestContext& request)
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
|
||||||
|
std::string get_book_name(const RequestContext& request)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
return request.get_url_part(0);
|
||||||
|
} catch (const std::out_of_range& e) {
|
||||||
|
return std::string();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} // unnamed namespace
|
||||||
|
|
||||||
Response InternalServer::handle_content(const RequestContext& request)
|
Response InternalServer::handle_content(const RequestContext& request)
|
||||||
{
|
{
|
||||||
if (m_verbose.load()) {
|
if (m_verbose.load()) {
|
||||||
|
@ -843,12 +857,7 @@ Response InternalServer::handle_content(const RequestContext& request)
|
||||||
|
|
||||||
kiwix::Entry entry;
|
kiwix::Entry entry;
|
||||||
|
|
||||||
std::string bookName;
|
const std::string bookName = get_book_name(request);
|
||||||
try {
|
|
||||||
bookName = request.get_url_part(0);
|
|
||||||
} catch (const std::out_of_range& e) {
|
|
||||||
return build_homepage(request);
|
|
||||||
}
|
|
||||||
if (bookName.empty())
|
if (bookName.empty())
|
||||||
return build_homepage(request);
|
return build_homepage(request);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue