diff --git a/src/http.c b/src/http.c index a5149a18..10afb215 100644 --- a/src/http.c +++ b/src/http.c @@ -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]; diff --git a/src/httpd.js.c b/src/httpd.js.c index fbddf92e..ca99e240 100644 --- a/src/httpd.js.c +++ b/src/httpd.js.c @@ -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);