Skip to content

Commit

Permalink
Fix parsing of Number arrays (#503)
Browse files Browse the repository at this point in the history
* Deseralize value from JSON not the index

Credits to @victorigualada

Co-Authored-By: victorigualada <[email protected]>

* Fix tests to match change

Co-Authored-By: victorigualada <[email protected]>

* Update CHANGELOG.md

---------

Co-authored-by: victorigualada <[email protected]>
  • Loading branch information
mrashed-dev and victorigualada authored Nov 21, 2023
1 parent cb42d16 commit 182e6cc
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Changelog

### Unreleased
* Fix parsing of Number arrays

### 6.10.0 / 2023-04-04
* Add support for verifying webhook signatures

Expand Down
6 changes: 3 additions & 3 deletions __tests__/calendar-restful-model-collection-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ describe('CalendarRestfulModelCollection', () => {
openHours: [
{
emails: ['[email protected]'],
days: [Days.Sunday],
days: [Days.Sunday, Days.Thursday],
timezone: 'America/Chicago',
start: '10:00',
end: '14:00',
Expand Down Expand Up @@ -200,7 +200,7 @@ describe('CalendarRestfulModelCollection', () => {
open_hours: [
{
emails: ['[email protected]'],
days: [0],
days: [6, 3],
timezone: 'America/Chicago',
start: '10:00',
end: '14:00',
Expand Down Expand Up @@ -306,7 +306,7 @@ describe('CalendarRestfulModelCollection', () => {
open_hours: [
{
emails: ['[email protected]', '[email protected]'],
days: [0],
days: [6],
timezone: 'America/Chicago',
start: '10:00',
end: '14:00',
Expand Down
4 changes: 2 additions & 2 deletions src/models/attributes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ class AttributeNumberList extends Attribute {
}
const nums = [];
for (const num in json) {
if (!isNaN(Number(num))) {
nums.push(Number(num));
if (!isNaN(Number(json[num]))) {
nums.push(Number(json[num]));
}
}
return nums;
Expand Down

0 comments on commit 182e6cc

Please sign in to comment.