11import assert from 'assert' ;
22import dataUriToBuffer from '../src' ;
33
4- describe ( 'data-uri-to-buffer' , function ( ) {
5- it ( 'should decode bare-bones Data URIs' , function ( ) {
4+ describe ( 'data-uri-to-buffer' , function ( ) {
5+ it ( 'should decode bare-bones Data URIs' , function ( ) {
66 const uri = 'data:,Hello%2C%20World!' ;
77
88 const buf = dataUriToBuffer ( uri ) ;
@@ -12,15 +12,15 @@ describe('data-uri-to-buffer', function() {
1212 assert . equal ( 'Hello, World!' , buf . toString ( ) ) ;
1313 } ) ;
1414
15- it ( 'should decode bare-bones "base64" Data URIs' , function ( ) {
15+ it ( 'should decode bare-bones "base64" Data URIs' , function ( ) {
1616 const uri = 'data:text/plain;base64,SGVsbG8sIFdvcmxkIQ%3D%3D' ;
1717
1818 const buf = dataUriToBuffer ( uri ) ;
1919 assert . equal ( 'text/plain' , buf . type ) ;
2020 assert . equal ( 'Hello, World!' , buf . toString ( ) ) ;
2121 } ) ;
2222
23- it ( 'should decode plain-text Data URIs' , function ( ) {
23+ it ( 'should decode plain-text Data URIs' , function ( ) {
2424 const html =
2525 '<!DOCTYPE html>' +
2626 '<html lang="en">' +
@@ -40,7 +40,7 @@ describe('data-uri-to-buffer', function() {
4040 // the next 4 tests are from:
4141 // https://bug161965.bugzilla.mozilla.org/attachment.cgi?id=94670&action=view
4242
43- it ( 'should decode "ISO-8859-8 in Base64" URIs' , function ( ) {
43+ it ( 'should decode "ISO-8859-8 in Base64" URIs' , function ( ) {
4444 const uri = 'data:text/plain;charset=iso-8859-8-i;base64,+ezl7Q==' ;
4545
4646 const buf = dataUriToBuffer ( uri ) ;
@@ -53,7 +53,7 @@ describe('data-uri-to-buffer', function() {
5353 assert . equal ( 0xed , buf [ 3 ] ) ;
5454 } ) ;
5555
56- it ( 'should decode "ISO-8859-8 in URL-encoding" URIs' , function ( ) {
56+ it ( 'should decode "ISO-8859-8 in URL-encoding" URIs' , function ( ) {
5757 const uri = 'data:text/plain;charset=iso-8859-8-i,%f9%ec%e5%ed' ;
5858
5959 const buf = dataUriToBuffer ( uri ) ;
@@ -66,7 +66,7 @@ describe('data-uri-to-buffer', function() {
6666 assert . equal ( 0xed , buf [ 3 ] ) ;
6767 } ) ;
6868
69- it ( 'should decode "UTF-8 in Base64" URIs' , function ( ) {
69+ it ( 'should decode "UTF-8 in Base64" URIs' , function ( ) {
7070 const uri = 'data:text/plain;charset=UTF-8;base64,16nXnNeV150=' ;
7171
7272 const buf = dataUriToBuffer ( uri ) ;
@@ -76,7 +76,7 @@ describe('data-uri-to-buffer', function() {
7676 assert . equal ( 'שלום' , buf . toString ( 'utf8' ) ) ;
7777 } ) ;
7878
79- it ( 'should decode "UTF-8 in URL-encoding" URIs' , function ( ) {
79+ it ( 'should decode "UTF-8 in URL-encoding" URIs' , function ( ) {
8080 const uri = 'data:text/plain;charset=UTF-8,%d7%a9%d7%9c%d7%95%d7%9d' ;
8181
8282 const buf = dataUriToBuffer ( uri ) ;
@@ -88,7 +88,7 @@ describe('data-uri-to-buffer', function() {
8888
8989 // this next one is from Wikipedia IIRC
9090
91- it ( 'should decode "base64" Data URIs with newlines' , function ( ) {
91+ it ( 'should decode "base64" Data URIs with newlines' , function ( ) {
9292 const uri =
9393 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUA\n' +
9494 'AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO\n' +
@@ -104,29 +104,29 @@ describe('data-uri-to-buffer', function() {
104104 ) ;
105105 } ) ;
106106
107- it ( 'should decode a plain-text URI with a space character in it' , function ( ) {
107+ it ( 'should decode a plain-text URI with a space character in it' , function ( ) {
108108 const uri = 'data:,foo bar' ;
109109
110110 const buf = dataUriToBuffer ( uri ) ;
111111 assert . equal ( 'text/plain' , buf . type ) ;
112112 assert . equal ( 'foo bar' , buf . toString ( ) ) ;
113113 } ) ;
114114
115- it ( 'should decode data with a "," comma char' , function ( ) {
115+ it ( 'should decode data with a "," comma char' , function ( ) {
116116 const uri = 'data:,a,b' ;
117117 const buf = dataUriToBuffer ( uri ) ;
118118 assert . equal ( 'text/plain' , buf . type ) ;
119119 assert . equal ( 'a,b' , buf . toString ( ) ) ;
120120 } ) ;
121121
122- it ( 'should decode data with traditionally reserved characters like ";"' , function ( ) {
122+ it ( 'should decode data with traditionally reserved characters like ";"' , function ( ) {
123123 const uri = 'data:,;test' ;
124124 const buf = dataUriToBuffer ( uri ) ;
125125 assert . equal ( 'text/plain' , buf . type ) ;
126126 assert . equal ( ';test' , buf . toString ( ) ) ;
127127 } ) ;
128128
129- it ( 'should not default to US-ASCII if main type is provided' , function ( ) {
129+ it ( 'should not default to US-ASCII if main type is provided' , function ( ) {
130130 const uri = 'data:text/plain,abc' ;
131131 const buf = dataUriToBuffer ( uri ) ;
132132 assert . equal ( 'text/plain' , buf . type ) ;
@@ -135,7 +135,7 @@ describe('data-uri-to-buffer', function() {
135135 assert . equal ( 'abc' , buf . toString ( ) ) ;
136136 } ) ;
137137
138- it ( 'should default to text/plain if main type is not provided' , function ( ) {
138+ it ( 'should default to text/plain if main type is not provided' , function ( ) {
139139 const uri = 'data:;charset=UTF-8,abc' ;
140140 const buf = dataUriToBuffer ( uri ) ;
141141 assert . equal ( 'text/plain' , buf . type ) ;
@@ -144,7 +144,7 @@ describe('data-uri-to-buffer', function() {
144144 assert . equal ( 'abc' , buf . toString ( ) ) ;
145145 } ) ;
146146
147- it ( 'should not allow charset without a leading ;' , function ( ) {
147+ it ( 'should not allow charset without a leading ;' , function ( ) {
148148 const uri = 'data:charset=UTF-8,abc' ;
149149 const buf = dataUriToBuffer ( uri ) ;
150150 assert . equal ( 'charset=UTF-8' , buf . type ) ;
@@ -153,7 +153,7 @@ describe('data-uri-to-buffer', function() {
153153 assert . equal ( 'abc' , buf . toString ( ) ) ;
154154 } ) ;
155155
156- it ( 'should allow custom media type parameters' , function ( ) {
156+ it ( 'should allow custom media type parameters' , function ( ) {
157157 const uri = 'data:application/javascript;version=1.8;charset=UTF-8,abc' ;
158158 const buf = dataUriToBuffer ( uri ) ;
159159 assert . equal ( 'application/javascript' , buf . type ) ;
@@ -165,7 +165,7 @@ describe('data-uri-to-buffer', function() {
165165 assert . equal ( 'abc' , buf . toString ( ) ) ;
166166 } ) ;
167167
168- it ( 'should allow base64 annotation anywhere' , function ( ) {
168+ it ( 'should allow base64 annotation anywhere' , function ( ) {
169169 const uri = 'data:text/plain;base64;charset=UTF-8,YWJj' ;
170170 const buf = dataUriToBuffer ( uri ) ;
171171 assert . equal ( 'text/plain' , buf . type ) ;
@@ -174,7 +174,7 @@ describe('data-uri-to-buffer', function() {
174174 assert . equal ( 'abc' , buf . toString ( ) ) ;
175175 } ) ;
176176
177- it ( 'should parse meta with unnecessary semicolons' , function ( ) {
177+ it ( 'should parse meta with unnecessary semicolons' , function ( ) {
178178 const uri = 'data:text/plain;;charset=UTF-8;;;base64;;;;,YWJj' ;
179179 const buf = dataUriToBuffer ( uri ) ;
180180 assert . equal ( 'text/plain' , buf . type ) ;
0 commit comments