rollback IsHTMLContentType

Kim committed Dec 11, 2025 at 16:58 UTC df26b5f471f3b3ae92fe6780656bd20d3694a1d0
1 file changed +14
utils/utils.go
+14
@@ -4,6 +4,7 @@ import (
4 "context"
5 "fmt"
6 "io"
7 + "mime"
8 "net/http"
9 "net/url"
10 "regexp"
@@ -127,6 +128,19 @@ func ParseURLs(raw string) []string {
128 return out
129 }
130
131 +// IsHTMLContentType checks if the Content-Type header indicates HTML content
132 +// It properly handles media type parsing with parameters like charset
133 +func IsHTMLContentType(contentType string) bool {
134 + if contentType == "" {
135 + return false
136 + }
137 + mediaType, _, err := mime.ParseMediaType(contentType)
138 + if err != nil {
139 + return strings.HasPrefix(strings.ToLower(contentType), "text/html")
140 + }
141 + return mediaType == "text/html"
142 +}
143 +
144 // GetContentType returns the MIME type for a file extension
145 func GetContentType(ext string) string {
146 switch ext {