forked from me-no-dev/ESPAsyncWebServer
fix serving url with no trailing /
This commit is contained in:
@@ -26,11 +26,11 @@ class AsyncStaticWebHandler: public AsyncWebHandler {
|
||||
_isFile = _fs.exists(path) || _fs.exists((String(path)+".gz").c_str());
|
||||
if (_uri != "/" && _uri.endsWith("/")) {
|
||||
_uri = _uri.substring(0, _uri.length() - 1);
|
||||
DEBUGF("[AsyncStaticWebHandler] _uri / removed");
|
||||
DEBUGF("[AsyncStaticWebHandler] _uri / removed\n");
|
||||
}
|
||||
if (_path != "/" && _path.endsWith("/")) {
|
||||
_path = _path.substring(0, _path.length() - 1);
|
||||
DEBUGF("[AsyncStaticWebHandler] _path / removed");
|
||||
DEBUGF("[AsyncStaticWebHandler] _path / removed\n");
|
||||
}
|
||||
|
||||
|
||||
|
@@ -9,7 +9,7 @@
|
||||
|
||||
#include "StringArray.h"
|
||||
|
||||
#define DEBUGF(...) //os_printf(__VA_ARGS__)
|
||||
#define DEBUGF(...) //Serial.printf(__VA_ARGS__)
|
||||
|
||||
|
||||
class AsyncWebServer;
|
||||
|
@@ -30,10 +30,13 @@ void AsyncStaticWebHandler::handleRequest(AsyncWebServerRequest *request)
|
||||
String baserequestUrl = request->url().substring(_uri.length()); // this is the request - stored _uri... /espman/
|
||||
DEBUGF(" baserequestUrl = %s\n", baserequestUrl.c_str());
|
||||
|
||||
if (baserequestUrl.length()) {
|
||||
path = _path + baserequestUrl;
|
||||
DEBUGF(" baserequestUrl length > 0: path = path + baserequestUrl, path = %s\n", path.c_str());
|
||||
if (!baserequestUrl.length()) {
|
||||
baserequestUrl += "/";
|
||||
}
|
||||
|
||||
path = _path + baserequestUrl;
|
||||
DEBUGF(" path = path + baserequestUrl, path = %s\n", path.c_str());
|
||||
|
||||
if (path.endsWith("/")) {
|
||||
DEBUGF(" 3 path ends with / : path = index.htm \n");
|
||||
path += "index.htm";
|
||||
|
Reference in New Issue
Block a user