diff options
author | 2024-05-20 22:13:55 +0200 | |
---|---|---|
committer | 2024-05-20 22:13:55 +0200 | |
commit | 30144aa3f51f5d0dc90f64cf888bc6f83de11b10 (patch) | |
tree | d3aae751a6c49a378b05f2135102628497f8103f /src/utils/base64.test.ts | |
parent | e876d0360812eab1255e414102a44d65f7c1bfaf (diff) | |
download | it-tools-30144aa3f51f5d0dc90f64cf888bc6f83de11b10.tar.gz it-tools-30144aa3f51f5d0dc90f64cf888bc6f83de11b10.tar.zst it-tools-30144aa3f51f5d0dc90f64cf888bc6f83de11b10.zip |
feat(base64): Base64 enhancements (#905)
* fix(base64): use js-base64 to handle non ascii text
Use js-base64 to handle non ascii text and ignore whitespaces
Fix #879 and #409
* fix(base64): use js-base64 to handle non ascii text
Use js-base64 to handle non ascii text and ignore whitespaces
Fix #879 and #409
* feat(base64 file converter): add a filename and extension fields
Add filename and extension (auto filled if data url) to allow downloading with right extension and filename
Fix #788
* feat(base64 file converter): add a preview image
Fix #594. Taken from #595 (thanks @SAF2k)
Diffstat (limited to 'src/utils/base64.test.ts')
-rw-r--r-- | src/utils/base64.test.ts | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/src/utils/base64.test.ts b/src/utils/base64.test.ts index 994f1b1..51d1523 100644 --- a/src/utils/base64.test.ts +++ b/src/utils/base64.test.ts @@ -38,7 +38,8 @@ describe('base64 utils', () => { it('should throw for incorrect base64 string', () => { expect(() => base64ToText('a')).to.throw('Incorrect base64 string'); - expect(() => base64ToText(' ')).to.throw('Incorrect base64 string'); + // should not really be false because trimming of space is now implied + // expect(() => base64ToText(' ')).to.throw('Incorrect base64 string'); expect(() => base64ToText('é')).to.throw('Incorrect base64 string'); // missing final '=' expect(() => base64ToText('bG9yZW0gaXBzdW0')).to.throw('Incorrect base64 string'); @@ -56,17 +57,17 @@ describe('base64 utils', () => { it('should return false for incorrect base64 string', () => { expect(isValidBase64('a')).to.eql(false); - expect(isValidBase64(' ')).to.eql(false); expect(isValidBase64('é')).to.eql(false); expect(isValidBase64('data:text/plain;notbase64,YQ==')).to.eql(false); // missing final '=' expect(isValidBase64('bG9yZW0gaXBzdW0')).to.eql(false); }); - it('should return false for untrimmed correct base64 string', () => { - expect(isValidBase64('bG9yZW0gaXBzdW0= ')).to.eql(false); - expect(isValidBase64(' LTE=')).to.eql(false); - expect(isValidBase64(' YQ== ')).to.eql(false); + it('should return true for untrimmed correct base64 string', () => { + expect(isValidBase64('bG9yZW0gaXBzdW0= ')).to.eql(true); + expect(isValidBase64(' LTE=')).to.eql(true); + expect(isValidBase64(' YQ== ')).to.eql(true); + expect(isValidBase64(' ')).to.eql(true); }); }); |