Skip to content

Commit

Permalink
feat: change gnoweb to add URL query arguments to render path
Browse files Browse the repository at this point in the history
  • Loading branch information
jeronimoalbi committed Oct 1, 2024
1 parent 01d9e8d commit 9d833f3
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions gno.land/pkg/gnoweb/gnoweb.go
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,10 @@ func handleRealmRender(logger *slog.Logger, app gotuna.App, cfg *Config, w http.
http.Redirect(w, r, "/r/"+rlmname, http.StatusFound)
return
}
if len(r.URL.RawQuery) > 0 {
q := filterQueryValues(r.URL.Query())
querystr = querystr + "?" + q.Encode()

Check warning on line 305 in gno.land/pkg/gnoweb/gnoweb.go

View check run for this annotation

Codecov / codecov/patch

gno.land/pkg/gnoweb/gnoweb.go#L304-L305

Added lines #L304 - L305 were not covered by tests
}
qpath := "vm/qrender"
data := []byte(fmt.Sprintf("%s:%s", rlmpath, querystr))
res, err := makeRequest(logger, cfg, qpath, data)
Expand Down Expand Up @@ -507,3 +511,16 @@ func pathOf(diruri string) string {

panic(fmt.Sprintf("invalid dir-URI %q", diruri))
}

func filterQueryValues(values url.Values) url.Values {
filtered := url.Values{}
for k, v := range values {

Check warning on line 517 in gno.land/pkg/gnoweb/gnoweb.go

View check run for this annotation

Codecov / codecov/patch

gno.land/pkg/gnoweb/gnoweb.go#L515-L517

Added lines #L515 - L517 were not covered by tests
// Filter out private gnoweb arguments
if strings.HasPrefix(k, "__") {
continue

Check warning on line 520 in gno.land/pkg/gnoweb/gnoweb.go

View check run for this annotation

Codecov / codecov/patch

gno.land/pkg/gnoweb/gnoweb.go#L519-L520

Added lines #L519 - L520 were not covered by tests
}

filtered[k] = v

Check warning on line 523 in gno.land/pkg/gnoweb/gnoweb.go

View check run for this annotation

Codecov / codecov/patch

gno.land/pkg/gnoweb/gnoweb.go#L523

Added line #L523 was not covered by tests
}
return filtered

Check warning on line 525 in gno.land/pkg/gnoweb/gnoweb.go

View check run for this annotation

Codecov / codecov/patch

gno.land/pkg/gnoweb/gnoweb.go#L525

Added line #L525 was not covered by tests
}

0 comments on commit 9d833f3

Please sign in to comment.