From d16183fad9aa6a3dfd7f3ecb4ddff2e16ac31247 Mon Sep 17 00:00:00 2001 From: Wil Wilsman Date: Fri, 31 Jan 2020 12:00:56 -0600 Subject: [PATCH] fix: clamp image dimensions to min and max When we render on our side, the full image should still be captured. --- src/services/image-snapshot-service.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/services/image-snapshot-service.ts b/src/services/image-snapshot-service.ts index 6caa4dae..7893c683 100644 --- a/src/services/image-snapshot-service.ts +++ b/src/services/image-snapshot-service.ts @@ -93,8 +93,9 @@ export default class ImageSnapshotService extends PercyClientService { ): Promise { return this.percyClient.createSnapshot(this.buildId, resources, { name, - widths: [width], - minimumHeight: height, + // clamp between 10px - 2000px + widths: [Math.max(10, Math.min(width, 2000))], + minimumHeight: Math.max(10, Math.min(height, 2000)), clientInfo: 'percy-upload', }).then(async (response: any) => { await this.percyClient.uploadMissingResources(this.buildId, response, resources)