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. */