0

I am trying to make a static webserver on an ESP32 via PlatformIO. I am using the built in "Upload Filesystem" task in PlatformIO to upload a www folder. I then use server.serveStatic("/", SPIFFS, "/www/"); to serve the pages. The issue is the url is case sensitive, and I need them to not be.

I assume this is due to the underlying SPIFFS filesystem, and to fix it I should somehow change that.

Kyle Berezin
  • 597
  • 4
  • 20
  • Not sure what you means 'case sensitive', I uses Arduino to upload data to SPIFFS (I actually can't make the upload to SPIFFS works on PlatformIO), and never have any issue. – hcheung Nov 23 '19 at 13:18
  • 192.168.4.1/Control.html works, but 192.168.4.1/control.html does not. I know sometimes this is intended, anything beyond the first / can be case sensitive, but I would prefer it if it were not. – Kyle Berezin Nov 26 '19 at 18:24

1 Answers1

1

Assuming you are using the standard ESP32 webserver library you could do the following: In your handler function compare the path argument you get with

webServer.uri()

which is a char array then use int strcasecmp(const char *s1, const char *s2); the function part would be

if (strcasecmp (webServer.uri(), "www/mysmallcapslink.html") == 0) {
... do your stuff here ...
e.g. serve the file
}

Note == 0 means the two strings (C-strings with small s) are identic (apart from the case). So url requests like www/Mysmallcapslink.html www/MySmallCapsLink.html would all be handled by the same handler.

Info about srtcasecmp:

DESCRIPTION The strcasecmp() function shall compare, while ignoring differences in case, the string pointed to by s1 to the string pointed to by s2. The strncasecmp() function shall compare, while ignoring differences in case, not more than n bytes from the string pointed to by s1 to the string pointed to by s2.

strncasecmp() shall behave as if the strings had been converted to lowercase and then a byte comparison performed.

RETURN VALUE Upon completion, strcasecmp() shall return an integer greater than, equal to, or less than 0, if the string pointed to by s1 is, ignoring case, greater than, equal to, or less than the string pointed to by s2, respectively.

Codebreaker007
  • 2,911
  • 1
  • 10
  • 22