MCPcopy Create free account
hub / github.com/coder/coder / parseAttributes

Function parseAttributes

scripts/gensite/generate_icon_list_test.go:78–97  ·  view source on GitHub ↗

parseAttributes parses a string of XML attributes into a map.

(attrsStr string)

Source from the content-addressed store, hash-verified

76
77// parseAttributes parses a string of XML attributes into a map.
78func parseAttributes(attrsStr string) map[string]string {
79 attrs := make(map[string]string)
80 if attrsStr == "" {
81 return attrs
82 }
83
84 // Match attribute="value" or attribute='value' patterns
85 attrRegex := regexp.MustCompile(`(\S+)=["']([^"']*)["']`)
86 matches := attrRegex.FindAllStringSubmatch(attrsStr, -1)
87
88 for _, match := range matches {
89 if len(match) >= 3 {
90 key := strings.TrimSpace(match[1])
91 value := match[2]
92 attrs[key] = value
93 }
94 }
95
96 return attrs
97}

Callers 1

parseSVGAttributesFunction · 0.85

Calls 1

MustCompileMethod · 0.80

Tested by

no test coverage detected