Fix /speedscope/ => deps/speedscope/index.html.

This commit is contained in:
Cory McWilliams 2024-05-08 20:57:53 -04:00
parent ba6da856bb
commit 5ca5323782
2 changed files with 17 additions and 3 deletions

View File

@ -147,12 +147,17 @@ static bool _http_pattern_matches(const char* pattern, const char* path, bool is
if (pattern[i] == '*')
{
for (; path[j]; j++)
while (true)
{
if (_http_pattern_matches(pattern + i + 1, path + j, strchr(pattern + i + 1, '*') != NULL))
{
return true;
}
if (!path[j])
{
break;
}
j++;
}
}
return !pattern[i] && !path[j];

View File

@ -626,11 +626,15 @@ static const char* _ext_to_content_type(const char* ext)
{
if (ext)
{
if (strcmp(ext, ".js") == 0 || strcmp(ext, ".mjs") == 0)
if (strcmp(ext, ".html") == 0)
{
return "text/html; charset=UTF-8";
}
else if (strcmp(ext, ".js") == 0 || strcmp(ext, ".mjs") == 0)
{
return "text/javascript; charset=UTF-8";
}
if (strcmp(ext, ".css") == 0)
else if (strcmp(ext, ".css") == 0)
{
return "text/css; charset=UTF-8";
}
@ -748,6 +752,11 @@ static void _httpd_endpoint_static(tf_http_request_t* request)
is_core = is_core || (after && i == 0);
}
if (strcmp(request->path, "/speedscope/") == 0)
{
after = "index.html";
}
if (!after || strstr(after, ".."))
{
const char* k_payload = tf_http_status_text(404);