Commit 05a9860
authored
[notification-hubs] fix TypeError when parsing AppleTemplateRegistrationDescription (#36114)
Currently `getHeadersOrUndefined` incorrectly assumes that the
`ApnsHeaders` parsed from XML is always an array. However, for single
XML element the XML parser gives back an object instead. This change
ensures we are iterating over an array.
One alternative approach is to add an option to `core-xml` specifying
whether to treat certain single xml elements as an object or the single
item of an array. Our underlying XML parser `fast-xml-parser` allows
passing in a `isArray: (name, jpath, isLeafNode, isAttribute) =>
boolean` predicate but it is specific to `fast-xml-parser` and it needs
more discussion on how to properly expose it in `core-xml`. For this
targeted scenario, it is good enough to check whether the parsed result
is an array. This package uses same pattern in other places too, for
example,
https://github.com/Azure/azure-sdk-for-js/blob/953fcf9f84b/sdk/notificationhubs/notification-hubs/src/serializers/notificationHubJobSerializer.ts#L611 parent cdbd31b commit 05a9860
3 files changed
Lines changed: 35 additions & 8 deletions
File tree
- sdk/notificationhubs/notification-hubs
- src/serializers
- test/internal/unit
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
4 | | - | |
5 | | - | |
6 | | - | |
7 | | - | |
| 3 | + | |
8 | 4 | | |
9 | 5 | | |
10 | 6 | | |
11 | | - | |
| 7 | + | |
12 | 8 | | |
13 | 9 | | |
14 | 10 | | |
| |||
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
502 | 502 | | |
503 | 503 | | |
504 | 504 | | |
505 | | - | |
| 505 | + | |
506 | 506 | | |
507 | 507 | | |
508 | 508 | | |
509 | 509 | | |
510 | 510 | | |
511 | 511 | | |
512 | | - | |
| 512 | + | |
513 | 513 | | |
514 | 514 | | |
515 | 515 | | |
| |||
Lines changed: 31 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
101 | 101 | | |
102 | 102 | | |
103 | 103 | | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
104 | 122 | | |
105 | 123 | | |
106 | 124 | | |
| |||
337 | 355 | | |
338 | 356 | | |
339 | 357 | | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
340 | 371 | | |
341 | 372 | | |
342 | 373 | | |
| |||
0 commit comments