diff --git a/html/html.go b/html/html.go
index eafcba0..7166644 100644
--- a/html/html.go
+++ b/html/html.go
@@ -83,7 +83,7 @@ func FileListPage(req string, entries []Entry) string {
-
+
@@ -110,16 +110,16 @@ func FileListPage(req string, entries []Entry) string {
if dirEntry.IsDir {
icon = "/assets/images/diricon.png"
}
- link := "/" + req + "." + dirEntry.Name
+ link := "/" + req + "/" + dirEntry.Name
if dirEntry.Name == ".." {
- splitReq := strings.Split(req, ".")
- link = "/" + strings.Join(splitReq[:len(splitReq)-1], ".")
+ splitReq := strings.Split(req, "/")
+ link = "/" + strings.Join(splitReq[:len(splitReq)-1], "/")
}
if req == "" {
link = "/" + req + dirEntry.Name
}
if !dirEntry.IsDir {
- link = "/serve/" + strings.ReplaceAll(req, ".", "/") + "/" + dirEntry.Name
+ link = "/serve/" + req + "/" + dirEntry.Name
}
body += fmt.Sprintf(`%s
%s
`, link, icon, dirEntry.Name, formattedSize)
}
diff --git a/leech b/leech
index 7049312..1578300 100755
Binary files a/leech and b/leech differ
diff --git a/main.go b/main.go
index e3108bf..cd0b5ae 100644
--- a/main.go
+++ b/main.go
@@ -21,8 +21,6 @@ func main() {
app.Use(logger.New(logger.Config{
Format: "[${ip}]:${port} ${status} - ${method} ${path}\n",
}))
- app.Get("/:req", route.HandleList)
- app.Get("/", route.HandleList)
app.Use("/assets", filesystem.New(filesystem.Config{
Root: http.FS(assetsEmbed),
@@ -34,5 +32,7 @@ func main() {
app.Static("/serve/"+url.QueryEscape(dirName), dirToServe)
}
+ app.Use("/", route.HandleList)
+
app.Listen(config.Config.Host)
}
diff --git a/route/route.go b/route/route.go
index eec4dd4..760d16d 100644
--- a/route/route.go
+++ b/route/route.go
@@ -1,6 +1,7 @@
package route
import (
+ "fmt"
"leech/config"
"leech/html"
"net/url"
@@ -36,7 +37,8 @@ func RecursivelyGetSize(completePath string) (int64, error) {
}
func HandleList(c *fiber.Ctx) error {
- encodedReq := c.Params("req")
+ encodedReq := c.Path()[1:]
+ fmt.Println(encodedReq)
req, err := url.QueryUnescape(encodedReq)
if err != nil {
return c.Status(fiber.StatusInternalServerError).SendString(err.Error())
@@ -66,8 +68,9 @@ func HandleList(c *fiber.Ctx) error {
return c.SendString(html.FileListPage(req, entries))
} else {
- pathSlice := strings.Split(req, ".")
+ pathSlice := strings.Split(req, "/")
pathBase, ok := config.Config.ServeDirs[pathSlice[0]]
+ fmt.Println(pathSlice[0])
if ok {
pathSlice[0] = pathBase
completePath := path.Join(pathSlice...)