From 9faedc2f9e9f296a14956fa0fe34429a91e6a307 Mon Sep 17 00:00:00 2001 From: Erik Pellizzon Date: Sat, 21 Dec 2024 22:00:44 +0100 Subject: [PATCH] Fix HTML public conditions (#594) --- ext/html/html.go | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/ext/html/html.go b/ext/html/html.go index cebae05a..af644afb 100644 --- a/ext/html/html.go +++ b/ext/html/html.go @@ -13,7 +13,24 @@ import ( "golang.org/x/text/transform" ) -var IsHtml = goproxy.ContentTypeIs("text/html") +var IsHtml goproxy.RespCondition = goproxy.ContentTypeIs("text/html") + +var IsCss goproxy.RespCondition = goproxy.ContentTypeIs("text/css") + +var IsJavaScript goproxy.RespCondition = goproxy.ContentTypeIs("text/javascript", + "application/javascript") + +var IsJson goproxy.RespCondition = goproxy.ContentTypeIs("text/json") + +var IsXml goproxy.RespCondition = goproxy.ContentTypeIs("text/xml") + +var IsWebRelatedText goproxy.RespCondition = goproxy.ContentTypeIs( + "text/html", + "text/css", + "text/javascript", "application/javascript", + "text/xml", + "text/json", +) // HandleString will receive a function that filters a string, and will convert the // request body to a utf8 string, according to the charset specified in the Content-Type