diff --git a/src/smol-http-pthreads.c b/src/smol-http-pthreads.c
index 9672f2a..c38093f 100644
--- a/src/smol-http-pthreads.c
+++ b/src/smol-http-pthreads.c
@@ -71,7 +71,7 @@ static void list_files(int ssl, char *directory) {
snprintf(path, sizeof(path), "%s/%s", directory, entry->d_name);
// if (stat(path, &st) < 0 || S_ISDIR(st.st_mode)) continue;
pos += snprintf(buf + pos, sizeof(buf) - pos,
- "
%s", directory, entry->d_name, entry->d_name);
+ "%s", directory, entry->d_name, entry->d_name);
}
closedir(dir);
diff --git a/src/smol-http.c b/src/smol-http.c
index 61a7cca..6da4a81 100644
--- a/src/smol-http.c
+++ b/src/smol-http.c
@@ -65,7 +65,7 @@ static void list_files(int ssl, char *directory) {
snprintf(path, sizeof(path), "%s/%s", directory, entry->d_name);
// if (stat(path, &st) < 0 || S_ISDIR(st.st_mode)) continue;
pos += snprintf(buf + pos, sizeof(buf) - pos,
- "%s", directory, entry->d_name, entry->d_name);
+ "%s", directory, entry->d_name, entry->d_name);
}
closedir(dir);
diff --git a/src/smol-pthreads.c b/src/smol-pthreads.c
index 5557b88..64f4311 100644
--- a/src/smol-pthreads.c
+++ b/src/smol-pthreads.c
@@ -73,7 +73,7 @@ static void list_files(SSL *ssl, char *directory) {
char path[MAX_PATH];
snprintf(path, sizeof(path), "%s/%s", directory, entry->d_name);
pos += snprintf(buf + pos, sizeof(buf) - pos,
- "%s", directory, entry->d_name, entry->d_name);
+ "%s", directory, entry->d_name, entry->d_name);
}
closedir(dir);
@@ -129,7 +129,12 @@ void *handle_request(void *param) {
char file_path[MAX_PATH];
snprintf(file_path, sizeof(file_path), "%s/%s", ROOT_DIR, path[0] == '/' ? path + 1 : path);
-
+ if (file_path[0] == "." && file_path[1] == "/") {
+ for (int i = 2; i < MAX_PATH -1; i++) {
+ file_path[i-2] = file_path[i];
+ }
+ }
+ https://localhost:8081/home/tola/Pictures/home/tola/Pictures/wallpaper/3d-tech.jpg
struct stat st;
if (stat(file_path, &st) < 0 || S_ISDIR(st.st_mode)) {
if (S_ISDIR(st.st_mode)) {
diff --git a/src/smol.c b/src/smol.c
index d46937c..ac17970 100644
--- a/src/smol.c
+++ b/src/smol.c
@@ -67,7 +67,7 @@ static void list_files(SSL *ssl, char *directory) {
snprintf(path, sizeof(path), "%s/%s", directory, entry->d_name);
// if (stat(path, &st) < 0 || S_ISDIR(st.st_mode)) continue;
pos += snprintf(buf + pos, sizeof(buf) - pos,
- "%s", directory, entry->d_name, entry->d_name);
+ "%s", directory, entry->d_name, entry->d_name);
}
closedir(dir);