Skip to content

Commit

Permalink
Merge pull request Azure#214 from abhishekgoenka/master
Browse files Browse the repository at this point in the history
Avoid split for undefined objects
  • Loading branch information
Dan Schulte authored Sep 5, 2018
2 parents c8ed5b1 + 0de3086 commit da56465
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions lib/serializer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -241,15 +241,17 @@ function base64UrlToByteArray(str: string): Uint8Array | undefined {
function splitSerializeName(prop: string): Array<string> {
const classes: Array<string> = [];
let partialclass = "";
const subwords = prop.split(".");
if (prop) {
const subwords = prop.split(".");

for (const item of subwords) {
if (item.charAt(item.length - 1) === "\\") {
partialclass += item.substr(0, item.length - 1) + ".";
} else {
partialclass += item;
classes.push(partialclass);
partialclass = "";
for (const item of subwords) {
if (item.charAt(item.length - 1) === "\\") {
partialclass += item.substr(0, item.length - 1) + ".";
} else {
partialclass += item;
classes.push(partialclass);
partialclass = "";
}
}
}

Expand Down Expand Up @@ -533,7 +535,7 @@ function deserializeCompositeType(serializer: Serializer, mapper: CompositeMappe
const propertyMapper = modelProps[key];
const { serializedName, xmlName, xmlElementName } = propertyMapper;
let propertyObjectName = objectName;
if (serializedName !== "") {
if (serializedName !== "" && serializedName !== undefined) {
propertyObjectName = objectName + "." + serializedName;
}

Expand Down

0 comments on commit da56465

Please sign in to comment.