mirror of
https://github.com/shlldev/miniws.git
synced 2025-09-02 19:00:59 +02:00
fix wwwFolder
This commit is contained in:
@@ -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
|
||||
|
||||
|
Reference in New Issue
Block a user