Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: change gnoweb to add URL query arguments to render path #2876

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
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 @@

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, "__") {
Copy link
Member Author

@jeronimoalbi jeronimoalbi Oct 1, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checking __ to allow _ prefix to users but otherwise checking _ should be done.

The "help" parameter is allowed to be pass to the render.

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
}
Loading