aboutsummaryrefslogtreecommitdiffhomepage
path: root/parser
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <[email protected]>2024-05-17 17:06:47 +0200
committerBjørn Erik Pedersen <[email protected]>2024-06-04 16:07:39 +0200
commit447108fed2842e264897659856e9fd9cdc32ca23 (patch)
tree53687693e04496919dd84266cc1edc16746101b0 /parser
parentc71e24af5172e230baa5f7dfa2078721cda38df4 (diff)
downloadhugo-447108fed2842e264897659856e9fd9cdc32ca23.tar.gz
hugo-447108fed2842e264897659856e9fd9cdc32ca23.zip
Add a HTTP cache for remote resources.
Fixes #12502 Closes #11891
Diffstat (limited to 'parser')
-rw-r--r--parser/lowercase_camel_json.go8
1 files changed, 7 insertions, 1 deletions
diff --git a/parser/lowercase_camel_json.go b/parser/lowercase_camel_json.go
index af0891de6..c61a4078e 100644
--- a/parser/lowercase_camel_json.go
+++ b/parser/lowercase_camel_json.go
@@ -46,6 +46,12 @@ type LowerCaseCamelJSONMarshaller struct {
Value any
}
+var preserveUpperCaseKeyRe = regexp.MustCompile(`^"HTTP`)
+
+func preserveUpperCaseKey(match []byte) bool {
+ return preserveUpperCaseKeyRe.Match(match)
+}
+
func (c LowerCaseCamelJSONMarshaller) MarshalJSON() ([]byte, error) {
marshalled, err := json.Marshal(c.Value)
@@ -59,7 +65,7 @@ func (c LowerCaseCamelJSONMarshaller) MarshalJSON() ([]byte, error) {
// Empty keys are valid JSON, only lowercase if we do not have an
// empty key.
- if len(match) > 2 {
+ if len(match) > 2 && !preserveUpperCaseKey(match) {
// Decode first rune after the double quotes
r, width := utf8.DecodeRune(match[1:])
r = unicode.ToLower(r)