From a07b95fe92da5280848896497dac11eb2edece93 Mon Sep 17 00:00:00 2001 From: acetone Date: Sun, 5 Dec 2021 05:23:56 -0500 Subject: [PATCH] bug fix for one named month and day (webUi) --- httpserver.cpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/httpserver.cpp b/httpserver.cpp index 4ade57e..73b7b08 100644 --- a/httpserver.cpp +++ b/httpserver.cpp @@ -228,11 +228,17 @@ void HttpServer::writeMainPage(QTcpSocket *socket, QString &urlPath) month = getWordFromPath(urlPath); month.remove(QRegularExpression("\\?.*$")); if (not month.isEmpty() and fsPath.cd(month)) { - urlPath.remove(QRegularExpression("^.*/"+month)); - day = getWordFromPath(urlPath); - day.remove(QRegularExpression("\\?.*$")); - if (not QFile::exists(fsPath.path()+global::slash+day+".txt")) { - day.clear(); + if (urlPath.startsWith("/"+month+"/")) { + urlPath.remove(0,1); + int pos = urlPath.indexOf('/'); + if (pos != -1) { + urlPath.remove(0,pos); + day = getWordFromPath(urlPath); + day.remove(QRegularExpression("\\?.*$")); + if (not QFile::exists(fsPath.path()+global::slash+day+".txt")) { + day.clear(); + } + } } } else { month.clear(); } @@ -454,7 +460,7 @@ void HttpServer::writeMainPage(QTcpSocket *socket, QString &urlPath) } /* If you are reading this code, maybe you are crying now. - * Sorry me, man (woman/forgot/etc). Maybe I'll refactor this hell in the future. + * Sorry me, man (woman/fagot/etc). Maybe I'll refactor this hell in the future. * acetone. */