From 9074a57e6f05f7d350f0ff750041bf0eb992a8e6 Mon Sep 17 00:00:00 2001 From: uan Date: Sun, 3 Aug 2025 16:24:25 +0200 Subject: [PATCH] fix wwwFolder --- miniws/webserver.go | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/miniws/webserver.go b/miniws/webserver.go index 4c92213..11f4bac 100644 --- a/miniws/webserver.go +++ b/miniws/webserver.go @@ -129,9 +129,6 @@ func (ws *WebServer) isUserAgentValid(userAgent string) bool { func (ws *WebServer) fetchFileContents(filepath string) ([]byte, error) { if filepath == "/" { filepath = "." - } else { - filepath_relative, _ := strings.CutPrefix(filepath, "/") - filepath = filepath_relative } fileinfo, err := os.Stat(filepath) if err != nil { @@ -153,7 +150,7 @@ func (ws *WebServer) get(writer http.ResponseWriter, req *http.Request) { return } - fetchedData, fetchErr := ws.fetchFileContents(ensureSlashSuffix(ws.wwwFolder) + req.URL.Path) + fetchedData, fetchErr := ws.fetchFileContents(ensureSlashSuffix(ws.wwwFolder) + strings.TrimPrefix(req.URL.Path, "/")) sentBytes := 0