summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 5341876)
raw | patch | inline | side by side (parent: 5341876)
author | Eric Wertz <ericwertz@Erics-MacBook-Pro.local> | |
Sun, 8 Jun 2025 20:37:24 +0000 (16:37 -0400) | ||
committer | Eric Wertz <ericwertz@Erics-MacBook-Pro.local> | |
Sun, 8 Jun 2025 20:37:24 +0000 (16:37 -0400) |
backend/StaticFileResponse.cpp | patch | blob | history |
index 1c32cfdbe5b7d8253a866b9e1e5a97a21a62403d..19e3f0e88cd999846b65a90bffa49c1e404addfc 100644 (file)
// CStaticFileResponse Implementation
CStaticFileResponse::CStaticFileResponse(const CHTTPRequest& request, std::string path) : CHTTPResponse(request)
{
+ // Remove query string from path for routing decisions
+ std::string clean_path = path;
+ size_t query_pos = clean_path.find('?');
+ if (query_pos != std::string::npos) {
+ clean_path = clean_path.substr(0, query_pos);
+ }
+
// Index is easy enough to handle
- if (path == "/")
+ if (clean_path == "/" )
{
serveFileFromPath("index.html");
return;
}
// Basic path normalization - remove duplicate slashes and handle relative paths
- std::string normalized;
+ std::string normalized = "/";
for (size_t i = 0; i < path.length(); i++) {
- if (path[i] == '/' && !normalized.empty() && normalized.back() == '/') {
+ if (path[i] == '/' && normalized.back() == '/') {
continue; // Skip duplicate slashes
}
normalized.push_back(path[i]);