Skip to content
This repository was archived by the owner on Apr 15, 2025. It is now read-only.

Commit e5dad51

Browse files
committed
Patched edge case bug for concurrent CacheableImage components mounting with same source url prop and updated tests appropriately.
1 parent dc0ec8d commit e5dad51

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

lib/FileSystem.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ export class FileSystem {
194194

195195
} else {
196196

197-
let result = await this.fetchFile(url, permanent);
197+
let result = await this.fetchFile(url, permanent, null, true); // Clobber must be true to allow concurrent CacheableImage components with same source url (ie: bullet point images).
198198
filePath = result.path;
199199

200200
}

lib/imageCacheHoc.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ export default function imageCacheHoc(Image, options = {}) {
7373
!traverse(this.props).get(['source', 'uri'])
7474
|| !validator.isURL(traverse(this.props).get(['source', 'uri']), validatorUrlOptions)
7575
) {
76-
throw new Error('Invalid source prop. <CacheableImage> props.source.uri should be a web accessible url.');
76+
throw new Error('Invalid source prop. <CacheableImage> props.source.uri should be a web accessible url with a valid protocol and host. NOTE: Default valid protocol is https, default valid hosts are *.');
7777
} else {
7878
return true;
7979
}

tests/CacheableImage.test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ describe('CacheableImage', function() {
6464

6565
throw new Error('Invalid source uri prop was accepted.');
6666
} catch (error) {
67-
error.should.deepEqual(new Error('Invalid source prop. <CacheableImage> props.source.uri should be a web accessible url.'));
67+
error.should.deepEqual(new Error('Invalid source prop. <CacheableImage> props.source.uri should be a web accessible url with a valid protocol and host. NOTE: Default valid protocol is https, default valid hosts are *.'));
6868
}
6969

7070
// Verify source uri prop only accepts web accessible urls from whitelist if whitelist set.
@@ -83,7 +83,7 @@ describe('CacheableImage', function() {
8383

8484
throw new Error('Invalid source uri prop was accepted.');
8585
} catch (error) {
86-
error.should.deepEqual(new Error('Invalid source prop. <CacheableImage> props.source.uri should be a web accessible url.'));
86+
error.should.deepEqual(new Error('Invalid source prop. <CacheableImage> props.source.uri should be a web accessible url with a valid protocol and host. NOTE: Default valid protocol is https, default valid hosts are *.'));
8787
}
8888

8989
// Verify source uri prop only accepts web accessible urls from correct protocols if protocol list set.
@@ -102,7 +102,7 @@ describe('CacheableImage', function() {
102102

103103
throw new Error('Invalid source uri prop was accepted.');
104104
} catch (error) {
105-
error.should.deepEqual(new Error('Invalid source prop. <CacheableImage> props.source.uri should be a web accessible url.'));
105+
error.should.deepEqual(new Error('Invalid source prop. <CacheableImage> props.source.uri should be a web accessible url with a valid protocol and host. NOTE: Default valid protocol is https, default valid hosts are *.'));
106106
}
107107

108108
});

0 commit comments

Comments
 (0)