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());
|
_isFile = _fs.exists(path) || _fs.exists((String(path)+".gz").c_str());
|
||||||
if (_uri != "/" && _uri.endsWith("/")) {
|
if (_uri != "/" && _uri.endsWith("/")) {
|
||||||
_uri = _uri.substring(0, _uri.length() - 1);
|
_uri = _uri.substring(0, _uri.length() - 1);
|
||||||
DEBUGF("[AsyncStaticWebHandler] _uri / removed");
|
DEBUGF("[AsyncStaticWebHandler] _uri / removed\n");
|
||||||
}
|
}
|
||||||
if (_path != "/" && _path.endsWith("/")) {
|
if (_path != "/" && _path.endsWith("/")) {
|
||||||
_path = _path.substring(0, _path.length() - 1);
|
_path = _path.substring(0, _path.length() - 1);
|
||||||
DEBUGF("[AsyncStaticWebHandler] _path / removed");
|
DEBUGF("[AsyncStaticWebHandler] _path / removed\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -9,7 +9,7 @@
|
|||||||
|
|
||||||
#include "StringArray.h"
|
#include "StringArray.h"
|
||||||
|
|
||||||
#define DEBUGF(...) //os_printf(__VA_ARGS__)
|
#define DEBUGF(...) //Serial.printf(__VA_ARGS__)
|
||||||
|
|
||||||
|
|
||||||
class AsyncWebServer;
|
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/
|
String baserequestUrl = request->url().substring(_uri.length()); // this is the request - stored _uri... /espman/
|
||||||
DEBUGF(" baserequestUrl = %s\n", baserequestUrl.c_str());
|
DEBUGF(" baserequestUrl = %s\n", baserequestUrl.c_str());
|
||||||
|
|
||||||
if (baserequestUrl.length()) {
|
if (!baserequestUrl.length()) {
|
||||||
path = _path + baserequestUrl;
|
baserequestUrl += "/";
|
||||||
DEBUGF(" baserequestUrl length > 0: path = path + baserequestUrl, path = %s\n", path.c_str());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
path = _path + baserequestUrl;
|
||||||
|
DEBUGF(" path = path + baserequestUrl, path = %s\n", path.c_str());
|
||||||
|
|
||||||
if (path.endsWith("/")) {
|
if (path.endsWith("/")) {
|
||||||
DEBUGF(" 3 path ends with / : path = index.htm \n");
|
DEBUGF(" 3 path ends with / : path = index.htm \n");
|
||||||
path += "index.htm";
|
path += "index.htm";
|
||||||
|
Reference in New Issue
Block a user