diff options
author | deneb <[email protected]> | 2024-05-18 20:55:36 +0200 |
---|---|---|
committer | GitHub <[email protected]> | 2024-05-18 12:55:36 -0600 |
commit | f98f449f05c251da2b25fe96ffb73319b4a7af76 (patch) | |
tree | edf5b73b310cd24f8a4b102a140c02ef7b45c710 /modules/caddyhttp/templates/tplcontext.go | |
parent | e66040a6f0b384d9cebd38a78f746f08f4cb22c1 (diff) | |
download | caddy-f98f449f05c251da2b25fe96ffb73319b4a7af76.tar.gz caddy-f98f449f05c251da2b25fe96ffb73319b4a7af76.zip |
templates: Add `pathEscape` template function and use it in file browser (#6278)
* use url.PathEscape in file-server browse template
- add `pathEscape` to c.tpl.Funcs, using `url.PathEscape`
- use `pathEscape` in browse.html in place of `replace`
* document `pathEscape`
* Remove unnecessary pipe of img src to `html`
Diffstat (limited to 'modules/caddyhttp/templates/tplcontext.go')
-rw-r--r-- | modules/caddyhttp/templates/tplcontext.go | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/modules/caddyhttp/templates/tplcontext.go b/modules/caddyhttp/templates/tplcontext.go index 4c7c86e13..2324586be 100644 --- a/modules/caddyhttp/templates/tplcontext.go +++ b/modules/caddyhttp/templates/tplcontext.go @@ -21,6 +21,7 @@ import ( "io/fs" "net" "net/http" + "net/url" "os" "path" "reflect" @@ -91,6 +92,7 @@ func (c *TemplateContext) NewTemplate(tplName string) *template.Template { "httpError": c.funcHTTPError, "humanize": c.funcHumanize, "maybe": c.funcMaybe, + "pathEscape": url.PathEscape, }) return c.tpl } |