mirror of
https://github.com/kiwix/kiwix-tools.git
synced 2025-09-23 03:52:35 -04:00
Handle search with no content and empty query string.
We need to handle : - No content because it is how we do multisearch. - No query string because it is how we can do geosearch.
This commit is contained in:
parent
04b05b7902
commit
9021f87715
@ -475,10 +475,11 @@ static struct MHD_Response* handle_search(RequestContext* request)
|
|||||||
std::string patternString;
|
std::string patternString;
|
||||||
try {
|
try {
|
||||||
humanReadableBookId = request->get_argument("content");
|
humanReadableBookId = request->get_argument("content");
|
||||||
|
} catch (const std::out_of_range&) {}
|
||||||
|
|
||||||
|
try {
|
||||||
patternString = request->get_argument("pattern");
|
patternString = request->get_argument("pattern");
|
||||||
} catch (const std::out_of_range&) {
|
} catch (const std::out_of_range&) {}
|
||||||
return build_homepage(request);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Retrive geo search */
|
/* Retrive geo search */
|
||||||
bool has_geo_query = false;
|
bool has_geo_query = false;
|
||||||
@ -502,7 +503,7 @@ static struct MHD_Response* handle_search(RequestContext* request)
|
|||||||
bool cacheEnabled = !(searcher == globalSearcher);
|
bool cacheEnabled = !(searcher == globalSearcher);
|
||||||
|
|
||||||
/* Try first to load directly the article */
|
/* Try first to load directly the article */
|
||||||
if (reader != nullptr) {
|
if (reader != nullptr && !patternString.empty()) {
|
||||||
std::string patternCorrespondingUrl;
|
std::string patternCorrespondingUrl;
|
||||||
auto variants = reader->getTitleVariants(patternString);
|
auto variants = reader->getTitleVariants(patternString);
|
||||||
auto variantsItr = variants.begin();
|
auto variantsItr = variants.begin();
|
||||||
@ -522,7 +523,7 @@ static struct MHD_Response* handle_search(RequestContext* request)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Make the search */
|
/* Make the search */
|
||||||
if (reader_searcher.second != nullptr &&
|
if (searcher != nullptr &&
|
||||||
(!patternString.empty() || has_geo_query)) {
|
(!patternString.empty() || has_geo_query)) {
|
||||||
auto start = 0;
|
auto start = 0;
|
||||||
try {
|
try {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user