Skip to content

Commit 06315d5

Browse files
Handle attributes with hypens in
1 parent 9a18574 commit 06315d5

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

env-model-generator/src/parse-spring-xml.ts

+5-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import * as _ from "lodash";
33
import * as spring from "../xmlns/www.springframework.org/schema/beans";
44
import { ConfigParseError } from "./ConfigParseError";
55
import * as model from "./model";
6-
import { parseXmlString } from "./utils";
6+
import { makeIdentifier, parseXmlString } from "./utils";
77

88
export default async function parseSpringXmlConfigFile(fileNames: string[]) {
99
// Avoid loading a file more than once or getting into a cyclic dependency loop
@@ -138,9 +138,11 @@ function flattenAttributes(obj: any) {
138138
// Now deal with $, which contains all the attributes
139139
if (obj.$) {
140140
for (const key in obj.$) {
141-
if (obj.$.hasOwnProperty(key))
141+
if (obj.$.hasOwnProperty(key)) {
142142
// Add the attributes as direct children of the object
143-
result[key] = obj.$[key];
143+
// If the name contains a hyphen, turn it into a valid identifier
144+
result[makeIdentifier(key)] = obj.$[key];
145+
}
144146
}
145147
}
146148
return result;

0 commit comments

Comments
 (0)