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

Commit 6fd29d7

Browse files
committed
Added tests for new BMP functionality and better support of remote image url parsing.
1 parent 0c690b0 commit 6fd29d7

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

tests/FileSystem.test.js

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ describe('lib/FileSystem', function() {
8484

8585
});
8686

87-
it('#getFileNameFromUrl should create a sha1 filename from a PNG/JPG/GIF url.', () => {
87+
it('#getFileNameFromUrl should create a sha1 filename from a PNG/JPG/GIF/BMP url.', () => {
8888

8989
const fileSystem = FileSystemFactory();
9090

@@ -100,6 +100,24 @@ describe('lib/FileSystem', function() {
100100

101101
jpgFilename.should.equal('6adf4569ecc3bf8c378bb4d47b1995cd85c5a13c.jpg');
102102

103+
let bmpFilename = fileSystem.getFileNameFromUrl('https://cdn-learn.adafruit.com/assets/assets/000/010/147/original/tiger.bmp');
104+
105+
bmpFilename.should.equal('282fb62d2caff367aff828ce21e79575733605c8.bmp');
106+
107+
});
108+
109+
it('#getFileNameFromUrl should handle urls with same pathname but different query strings or fragments as individual files.', () => {
110+
111+
const fileSystem = FileSystemFactory();
112+
113+
const pngFilename = fileSystem.getFileNameFromUrl('https://img.wennermedia.com/5333a62d-07db-432a-92e2-198cafa38a14-326adb1a-d8ed-4a5d-b37e-5c88883e1989.png?exampleparam=one&anotherparam=2#this-is-a-fragment');
114+
115+
pngFilename.should.equal('9eea25bf871c2333648080180f6b616a91ce1b09.png');
116+
117+
const pngFilenameTwo = fileSystem.getFileNameFromUrl('https://img.wennermedia.com/5333a62d-07db-432a-92e2-198cafa38a14-326adb1a-d8ed-4a5d-b37e-5c88883e1989.png?exampleparam=DIFFERENT&anotherparam=2#this-is-a-fragment-two');
118+
119+
pngFilenameTwo.should.equal('09091b8880ddb982968a0fe28abed5034f9a43b8.png');
120+
103121
});
104122

105123
it('#getLocalFilePathFromUrl should return local filepath if it exists on local fs in permanent dir.', () => {

0 commit comments

Comments
 (0)