refactor(upload): move Regex to variable

This commit is contained in:
2026-02-09 08:19:30 +01:00
parent 823f5f091a
commit 6cf349bafa
2 changed files with 5 additions and 3 deletions

View File

@@ -27,9 +27,9 @@ func Create(svgbuf []byte) (svg.TemplateData, error) {
return data, nil
}
func populateKeys(data *svg.TemplateData, svg []byte) {
regex := regexp.MustCompile(`\{\{\s*(.*?)\s*\}\}`)
result := regex.FindAllSubmatch(svg, -1)
func populateKeys(data *svg.TemplateData, svgblob []byte) {
regex := regexp.MustCompile(svg.KeyRegex)
result := regex.FindAllSubmatch(svgblob, -1)
templateKeys := make([]string, len(result))
for i, matches := range result {

View File

@@ -1,5 +1,7 @@
package svg
const KeyRegex string = `\{\{\s*(.*?)\s*\}\}`
type TemplateData struct {
Id string
TemplateKeys []string