aboutsummaryrefslogtreecommitdiff
path: root/src/client/util/request-image-size.ts
diff options
context:
space:
mode:
authoreleanor-park <eleanor_park@brown.edu>2024-09-22 15:40:29 -0400
committereleanor-park <eleanor_park@brown.edu>2024-09-22 15:40:29 -0400
commit6d0cec80757dcdb07434d7788dd2eb97c2ce4b7c (patch)
tree58bc45587534b17a5bb340e8e5bafc47a749f14f /src/client/util/request-image-size.ts
parent692076b1356309111c4f2cb69cbdbf4be1a825bd (diff)
parent97c150a2b53ccb27921125d55c9cbf42abf3c588 (diff)
Merge branch 'eleanor-gptdraw' of https://github.com/brown-dash/Dash-Web into eleanor-gptdraw
Diffstat (limited to 'src/client/util/request-image-size.ts')
-rw-r--r--src/client/util/request-image-size.ts9
1 files changed, 4 insertions, 5 deletions
diff --git a/src/client/util/request-image-size.ts b/src/client/util/request-image-size.ts
index 7a2ecd486..c619192ed 100644
--- a/src/client/util/request-image-size.ts
+++ b/src/client/util/request-image-size.ts
@@ -35,7 +35,11 @@ module.exports = function requestImageSize(url: string) {
res.on('data', chunk => {
buffer = Buffer.concat([buffer, chunk]);
+ });
+
+ res.on('error', reject);
+ res.on('end', () => {
try {
size = imageSize(buffer);
if (size) {
@@ -46,11 +50,6 @@ module.exports = function requestImageSize(url: string) {
/* empty */
console.log('Error: ', err);
}
- });
-
- res.on('error', reject);
-
- res.on('end', () => {
if (!size) {
reject(new Error('Image has no size'));
return;