File tree Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -129,6 +129,29 @@ describe("Multipart", function () {
129129 expect ( parsedMultipart . parts ) . to . be . empty ;
130130 } ) ;
131131
132+ it ( "should parse Multipart from empty Component bytes" , function ( ) {
133+ const multipart = new Multipart ( [ new Component ( { } ) ] ) ;
134+ const multipartBytes = multipart . bytes ( ) ;
135+ const parsedMultipart = Multipart . parse ( multipartBytes ) ;
136+ expect ( parsedMultipart ) . to . be . an . instanceof ( Multipart ) ;
137+ expect ( parsedMultipart . parts . length ) . to . equal ( 1 ) ;
138+ expect ( new TextDecoder ( ) . decode ( parsedMultipart . parts [ 0 ] . bytes ( ) ) ) . to . equal ( "\r\n" ) ;
139+ } ) ;
140+
141+ it ( "should handle parsing of empty parts in multipart MIME string" , function ( ) {
142+ const string = "Content-type: multipart/mixed; boundary=\"simple boundary\"\r\n\r\n"
143+ + "--simple boundary\r\n"
144+ + "\r\n"
145+ + "\r\n"
146+ + "--simple boundary--\r\n" ;
147+ const multipart = Multipart . parse ( new TextEncoder ( ) . encode ( string ) ) ;
148+ const multipartBytes = multipart . bytes ( ) ;
149+ const parsedMultipart = Multipart . parse ( multipartBytes ) ;
150+ expect ( parsedMultipart ) . to . be . an . instanceof ( Multipart ) ;
151+ expect ( parsedMultipart . parts . length ) . to . equal ( 1 ) ;
152+ expect ( new TextDecoder ( ) . decode ( parsedMultipart . parts [ 0 ] . bytes ( ) ) ) . to . equal ( "\r\n" ) ;
153+ } ) ;
154+
132155 it ( "should ignore linear whitespace after boundary delimiter" , function ( ) {
133156 const string =
134157 '--simple boundary \r\n' +
You can’t perform that action at this time.
0 commit comments