web frontend for git repositories, written in Go git.pocka.jp/legit.git
3

Configure Feed

Select the types of activity you want to include in your feed.

Fix weird URL search parameter handling (raw=true)

A query component in URL does not have to be "key=value". In fact,
browsers interpret that as a URLSearchParams, a list of "key" or
"key=value" allowing a same key appearing multiple times. You don't have
to set "true" or "false": simply set the key or remove the one.

Shota FUJI (Jul 11, 2026, 9:23 PM +0900) 2b352672 09c5f871

+4 -8
+1 -1
routes/preview/renderer.go
··· 45 45 } 46 46 47 47 queries := parsedURL.Query() 48 - queries.Add("raw", "1") 48 + queries.Add("raw", "") 49 49 parsedURL.RawQuery = queries.Encode() 50 50 51 51 node.LinkData.Destination = []byte(parsedURL.String())
+2 -6
routes/routes.go
··· 11 11 "os" 12 12 "path/filepath" 13 13 "sort" 14 - "strconv" 15 14 "strings" 16 15 17 16 securejoin "github.com/cyphar/filepath-securejoin" ··· 156 155 } 157 156 158 157 if node.Type == blackfriday.Image { 159 - node.LinkData.Destination = fmt.Appendf([]byte{}, "/%s/blob/%s/%s?raw=true", name, mainBranch, href) 158 + node.LinkData.Destination = fmt.Appendf([]byte{}, "/%s/blob/%s/%s?raw", name, mainBranch, href) 160 159 } else if strings.LastIndexByte(href, '/') == len(href)-1 { 161 160 node.LinkData.Destination = fmt.Appendf([]byte{}, "/%s/tree/%s/%s", name, mainBranch, href) 162 161 node.LinkData.Destination = node.LinkData.Destination[:len(node.LinkData.Destination)-1] ··· 284 283 } 285 284 286 285 func (d *deps) FileContent(w http.ResponseWriter, r *http.Request) { 287 - var raw bool 288 - if rawParam, err := strconv.ParseBool(r.URL.Query().Get("raw")); err == nil { 289 - raw = rawParam 290 - } 286 + raw := r.URL.Query().Has("raw") 291 287 292 288 name := r.PathValue("name") 293 289 if d.isIgnored(name) {
+1 -1
templates/repo-blob-ref.html.tmpl
··· 75 75 {{- template "tab-selector" -}} 76 76 <dt class="metadata--key">Raw</dt> 77 77 <dd class="metadata--value"> 78 - <a href="?raw=true">View raw</a> 78 + <a href="?raw">View raw</a> 79 79 </dd> 80 80 {{- range .PreviewTypes -}} 81 81 <dt class="metadata--key">Preview (<span class="preview-type">{{ . }}</span>)</dt>