mirror of
https://github.com/caddyserver/caddy.git
synced 2025-10-19 07:43:17 +00:00
admin: Preserve "@id" fields through partial changes (fixes #2902)
This commit is contained in:
parent
8de1a76227
commit
6e10586303
2 changed files with 33 additions and 11 deletions
7
admin.go
7
admin.go
|
@ -27,6 +27,7 @@ import (
|
|||
"net/url"
|
||||
"os"
|
||||
"path"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
|
@ -764,6 +765,12 @@ var (
|
|||
}
|
||||
)
|
||||
|
||||
// idRegexp is used to match ID fields and their associated values
|
||||
// in the config. It also matches adjacent commas so that syntax
|
||||
// can be preserved no matter where in the object the field appears.
|
||||
// It supports string and most numeric values.
|
||||
var idRegexp = regexp.MustCompile(`(?m),?\s*"` + idKey + `":\s?(-?[0-9]+(\.[0-9]+)?|(?U)".*")\s*,?`)
|
||||
|
||||
const (
|
||||
rawConfigKey = "config"
|
||||
idKey = "@id"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue