Skip to content

Commit

Permalink
chore: semantic changes
Browse files Browse the repository at this point in the history
  • Loading branch information
jeronimoalbi committed Nov 3, 2024
1 parent c78812c commit 434acf2
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions gno.land/pkg/gnoweb/gnoweb.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ import (
)

const (
qFileStr = "vm/qfile"
privQuerySeparator = "$"
querySeparator = "?"
qFileStr = "vm/qfile"
gnowebArgsSeparator = "$"
urlQuerySeparator = "?"
)

//go:embed views/*
Expand Down Expand Up @@ -310,12 +310,12 @@ func handleRealmRender(logger *slog.Logger, app gotuna.App, cfg *Config, w http.
return
}

var publicQuery, privateQuery string
var urlQuery, gnowebQuery string

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

View check run for this annotation

Codecov / codecov/patch

gno.land/pkg/gnoweb/gnoweb.go#L311-L313

Added lines #L311 - L313 were not covered by tests
if len(queryArgs) > 0 {
publicQuery = querySeparator + queryArgs.Encode()
urlQuery = urlQuerySeparator + queryArgs.Encode()
}
if len(gnowebArgs) > 0 {
privateQuery = privQuerySeparator + gnowebArgs.Encode()
gnowebQuery = gnowebArgsSeparator + gnowebArgs.Encode()
}

vars := mux.Vars(r)
Expand All @@ -324,12 +324,12 @@ func handleRealmRender(logger *slog.Logger, app gotuna.App, cfg *Config, w http.
querystr := vars["querystr"]
if r.URL.Path == "/r/"+rlmname+":" {
// Redirect to /r/REALM if querypath is empty.
http.Redirect(w, r, "/r/"+rlmname+publicQuery+privateQuery, http.StatusFound)
http.Redirect(w, r, "/r/"+rlmname+urlQuery+gnowebQuery, http.StatusFound)
return
}

qpath := "vm/qrender"
data := []byte(fmt.Sprintf("%s:%s", rlmpath, querystr+publicQuery))
data := []byte(fmt.Sprintf("%s:%s", rlmpath, querystr+urlQuery))
res, err := makeRequest(logger, cfg, qpath, data)
if err != nil {
// XXX hack
Expand Down Expand Up @@ -358,7 +358,7 @@ func handleRealmRender(logger *slog.Logger, app gotuna.App, cfg *Config, w http.

// Add URL query arguments to the last breadcrumb item's URL
if i+1 == len(queryParts) {

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

View check run for this annotation

Codecov / codecov/patch

gno.land/pkg/gnoweb/gnoweb.go#L357-L360

Added lines #L357 - L360 were not covered by tests
rlmpath = rlmpath + publicQuery + privateQuery
rlmpath = rlmpath + urlQuery + gnowebQuery
}

pathLinks = append(pathLinks, pathLink{
Expand Down Expand Up @@ -549,7 +549,7 @@ func pathOf(diruri string) string {
// the special "$" symbol. The "$" symbol can be used within public query
// arguments by using its encoded representation "%24".
func parseQueryArgs(rawURL string) (url.Values, error) {
if i := strings.Index(rawURL, privQuerySeparator); i != -1 {
if i := strings.Index(rawURL, gnowebArgsSeparator); i != -1 {
rawURL = rawURL[:i]
}

Expand All @@ -564,7 +564,7 @@ func parseQueryArgs(rawURL string) (url.Values, error) {
// These arguments are indicated by using the "$" symbol followed by a query
// string with the arguments.
func parseGnowebArgs(rawURL string) (url.Values, error) {

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

View check run for this annotation

Codecov / codecov/patch

gno.land/pkg/gnoweb/gnoweb.go#L565-L566

Added lines #L565 - L566 were not covered by tests
i := strings.Index(rawURL, privQuerySeparator)
i := strings.Index(rawURL, gnowebArgsSeparator)
if i == -1 {
return url.Values{}, nil
}
Expand Down

0 comments on commit 434acf2

Please sign in to comment.