forked from cory/tildefriends
Move last remnant of static file handling from core to C.
This commit is contained in:
@ -905,14 +905,23 @@ static void _httpd_endpoint_static(tf_http_request_t* request)
|
||||
const char* file_path = NULL;
|
||||
for (int i = 0; i < tf_countof(k_map) && !after; i++)
|
||||
{
|
||||
after = _after(request->path, k_map[i][0]);
|
||||
file_path = k_map[i][1];
|
||||
is_core = is_core || (after && i == 0);
|
||||
const char* next_after = _after(request->path, k_map[i][0]);
|
||||
if (next_after)
|
||||
{
|
||||
after = next_after;
|
||||
file_path = k_map[i][1];
|
||||
is_core = after && i == 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (strcmp(request->path, "/speedscope/") == 0)
|
||||
if ((!after || !*after) && request->path[strlen(request->path) - 1] == '/')
|
||||
{
|
||||
after = "index.html";
|
||||
if (!file_path)
|
||||
{
|
||||
file_path = "core/";
|
||||
is_core = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!after || strstr(after, ".."))
|
||||
@ -1668,6 +1677,7 @@ void tf_httpd_register(JSContext* context)
|
||||
tf_http_add_handler(http, "/speedscope/*", _httpd_endpoint_static, NULL, task);
|
||||
tf_http_add_handler(http, "/static/*", _httpd_endpoint_static, NULL, task);
|
||||
tf_http_add_handler(http, "/.well-known/*", _httpd_endpoint_static, NULL, task);
|
||||
tf_http_add_handler(http, "/~*/*/", _httpd_endpoint_static, NULL, task);
|
||||
|
||||
tf_http_add_handler(http, "/robots.txt", _httpd_endpoint_robots_txt, NULL, NULL);
|
||||
tf_http_add_handler(http, "/debug", _httpd_endpoint_debug, NULL, task);
|
||||
|
Reference in New Issue
Block a user