diff options
author | tjp <tjp@ctrl-c.club> | 2023-11-14 09:39:53 -0700 |
---|---|---|
committer | tjp <tjp@ctrl-c.club> | 2023-11-14 09:39:53 -0700 |
commit | c22799fa12c99932fc4620fce2dc0994567a52af (patch) | |
tree | 5c89892e82f0ca805af976a2d2038a690152d4c6 /gopher/gophermap/extended.go | |
parent | e599f0e2d4f8177143478ba17189e1ef656b7fe0 (diff) |
bugfixes from the Protocol refactorv1.6.0
Diffstat (limited to 'gopher/gophermap/extended.go')
-rw-r--r-- | gopher/gophermap/extended.go | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/gopher/gophermap/extended.go b/gopher/gophermap/extended.go index f2ca3fc..910adc0 100644 --- a/gopher/gophermap/extended.go +++ b/gopher/gophermap/extended.go @@ -307,7 +307,7 @@ func ExtendMiddleware(fsroot, urlroot string, settings *FileSystemSettings) sr.M return sr.HandlerFunc(func(ctx context.Context, request *sr.Request) *sr.Response { response := handler.Handle(ctx, request) - if !settings.ParseExtended || response.Status != gopher.MenuType { + if settings == nil || response == nil || !settings.ParseExtended || response.Status != gopher.MenuType { return response } @@ -322,7 +322,12 @@ func ExtendMiddleware(fsroot, urlroot string, settings *FileSystemSettings) sr.M fpath = strings.Trim(fpath, "/") fpath = filepath.Join(fsroot, fpath) - doc, _, err := edoc.Compatible(filepath.Dir(fpath), *settings) + cwd := fpath + if !strings.HasSuffix(request.Path, "/") { + cwd = filepath.Dir(cwd) + } + + doc, _, err := edoc.Compatible(cwd, *settings) if err != nil { return gopher.Error(err).Response() } |