From d60a53a06add1248e7d6ed9e6636d212ed43662a Mon Sep 17 00:00:00 2001 From: Runxi Yu Date: Fri, 7 Mar 2025 18:50:12 +0800 Subject: http/templates: Add query_escape and path_escape --- http_template_funcs.go | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'http_template_funcs.go') diff --git a/http_template_funcs.go b/http_template_funcs.go index 119a800..a7ebb1e 100644 --- a/http_template_funcs.go +++ b/http_template_funcs.go @@ -6,6 +6,7 @@ package main import ( "path" "strings" + "net/url" ) func first_line(s string) string { @@ -16,3 +17,11 @@ func first_line(s string) string { func base_name(s string) string { return path.Base(s) } + +func path_escape(s string) string { + return url.PathEscape(s) +} + +func query_escape(s string) string { + return url.QueryEscape(s) +} -- cgit v1.2.3