Skip to content

Commit 49ae904

Browse files
committed
Guard against zero dorm capacity division.
1 parent b1fd066 commit 49ae904

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

src/app/Services/Hostelworld/Api/AvailabilityClient.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,12 @@ export class AvailabilityClient {
112112
availability: HostelworldPropertyAvailability
113113
): void {
114114
for (const dorm of availability.rooms.dorms) {
115+
const capacity: number = Number(dorm.capacity)
116+
if (!capacity) continue
117+
115118
dorm.totalBedsAvailable = Math.ceil(
116-
dorm.totalBedsAvailable / Number(dorm.capacity)
117-
) * Number(dorm.capacity)
119+
dorm.totalBedsAvailable / capacity
120+
) * capacity
118121
}
119122
}
120123

0 commit comments

Comments
 (0)