diff options
-rw-r--r-- | gopher/gophermap/extended.go | 5 | ||||
-rw-r--r-- | gopher/gophermap/extended_test.go | 6 | ||||
-rw-r--r-- | internal/server.go | 9 | ||||
-rw-r--r-- | spartan/request.go | 14 | ||||
-rw-r--r-- | spartan/request_test.go | 1 |
5 files changed, 22 insertions, 13 deletions
diff --git a/gopher/gophermap/extended.go b/gopher/gophermap/extended.go index 7d64fe0..f2ca3fc 100644 --- a/gopher/gophermap/extended.go +++ b/gopher/gophermap/extended.go @@ -193,6 +193,7 @@ func (edoc *ExtendedMapDocument) Compatible(cwd string, settings FileSystemSetti hidden := map[string]struct{}{} extensions := map[string]types.Status{} +lineloop: for num, item := range edoc.Lines { switch item.Type { case CommentType: @@ -252,9 +253,9 @@ func (edoc *ExtendedMapDocument) Compatible(cwd string, settings FileSystemSetti doc = append(doc, dirlist...) - break + break lineloop case EndDocType: - break + break lineloop default: doc = append(doc, item) } diff --git a/gopher/gophermap/extended_test.go b/gopher/gophermap/extended_test.go index 0c8b647..5210984 100644 --- a/gopher/gophermap/extended_test.go +++ b/gopher/gophermap/extended_test.go @@ -66,6 +66,9 @@ func TestUptimeOutput(t *testing.T) { Path: "/customlist.gophermap", }) _ = file.Close() + if err != nil { + t.Fatal(err) + } doc, _, err := edoc.Compatible("testdata", FileSystemSettings{ ParseExtended: true, @@ -82,6 +85,9 @@ func TestUptimeOutput(t *testing.T) { expected, err := io.ReadAll(file) _ = file.Close() + if err != nil { + t.Fatal(err) + } if string(expected) != got { fmt.Printf("expected:\n%s", string(expected)) diff --git a/internal/server.go b/internal/server.go index 21d1a7f..46b95ef 100644 --- a/internal/server.go +++ b/internal/server.go @@ -44,10 +44,11 @@ func NewServer( baseLog = log.NewNopLogger() } errlog := level.Error(baseLog) - ctx = context.WithValue(ctx, "debuglog", level.Debug(baseLog)) - ctx = context.WithValue(ctx, "infolog", level.Info(baseLog)) - ctx = context.WithValue(ctx, "warnlog", level.Warn(baseLog)) - ctx = context.WithValue(ctx, "errlog", errlog) + + ctx = context.WithValue(ctx, "debuglog", level.Debug(baseLog)) //nolint:staticcheck + ctx = context.WithValue(ctx, "infolog", level.Info(baseLog)) //nolint:staticcheck + ctx = context.WithValue(ctx, "warnlog", level.Warn(baseLog)) //nolint:staticcheck + ctx = context.WithValue(ctx, "errlog", errlog) //nolint:staticcheck return Server{ Ctx: ctx, diff --git a/spartan/request.go b/spartan/request.go index d6a06f3..aa696fa 100644 --- a/spartan/request.go +++ b/spartan/request.go @@ -44,18 +44,20 @@ func ParseRequest(rdr io.Reader) (*types.Request, int, error) { return nil, 0, InvalidRequestLine } + u, err := url.Parse(path) + if err != nil { + return nil, 0, err + } + u.Scheme = "spartan" + u.Host = host + contentlen, err := strconv.Atoi(rest) if err != nil { return nil, 0, err } return &types.Request{ - URL: &url.URL{ - Scheme: "spartan", - Host: host, - Path: path, - RawPath: path, - }, + URL: u, Meta: &io.LimitedReader{R: bufrdr, N: int64(contentlen)}, }, contentlen, nil } diff --git a/spartan/request_test.go b/spartan/request_test.go index 89326f1..cb15459 100644 --- a/spartan/request_test.go +++ b/spartan/request_test.go @@ -38,7 +38,6 @@ func TestParseRequest(t *testing.T) { assert.Equal(t, test.host, request.Host) assert.Equal(t, test.path, request.Path) - assert.Equal(t, test.path, request.RawPath) assert.Equal(t, test.clen, clen) }) } |