mirror of https://notabug.org/acetone/ircabot.git
fix for search request in main page /
parent
f6c1d02351
commit
a83df8b12c
|
@ -145,6 +145,7 @@ QString HttpServer::getRequestPath(const QString &req)
|
|||
if (req.isEmpty()) return QString();
|
||||
|
||||
QString result(req);
|
||||
|
||||
int begin = result.indexOf(' ');
|
||||
if (begin == -1) return QString();
|
||||
|
||||
|
@ -161,6 +162,7 @@ QString HttpServer::getRequestPath(const QString &req)
|
|||
QString HttpServer::getWordFromPath(const QString &path)
|
||||
{
|
||||
QString result {path};
|
||||
result.remove(QRegularExpression("\\?.*$")); // any actions like a ?toSearch=
|
||||
if (result.startsWith('/')) {
|
||||
result.remove(QRegularExpression("^/"));
|
||||
}
|
||||
|
@ -181,6 +183,12 @@ void HttpServer::replaceTag(QString &page, const QString &tag, const QString &pa
|
|||
|
||||
void HttpServer::writeMainPage(QTcpSocket *socket, QString &urlPath)
|
||||
{
|
||||
QString searchRequest;
|
||||
int specSymbol = urlPath.indexOf('?'); // any actions like a ?toSearch=
|
||||
if (specSymbol != -1) {
|
||||
searchRequest = global::getValue(urlPath, "toSearch", global::eForWeb);
|
||||
urlPath.remove(specSymbol, urlPath.size()-specSymbol);
|
||||
}
|
||||
if (urlPath == "/") {
|
||||
urlPath += m_mainChannel;
|
||||
}
|
||||
|
@ -382,7 +390,6 @@ void HttpServer::writeMainPage(QTcpSocket *socket, QString &urlPath)
|
|||
//// Main section body compilation
|
||||
QString payloadBlock;
|
||||
|
||||
QString searchRequest = global::getValue(urlPath, "toSearch", global::eForWeb);
|
||||
// Search request
|
||||
if (not searchRequest.isEmpty()) {
|
||||
QRegularExpression userRgx(searchRequest, QRegularExpression::CaseInsensitiveOption);
|
||||
|
|
Loading…
Reference in New Issue