File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -40,7 +40,7 @@ const Resource = {
4040 } ,
4141
4242 generateDoc ( { body : content , response } ) {
43- const { 'content-type' : contentType } = response . headers ;
43+ const { 'content-type' : contentType = '' } = response . headers ;
4444
4545 // TODO: Implement is_text function from
4646 // https://github.com/ReadabilityHoldings/readability/blob/8dc89613241d04741ebd42fa9fa7df1b1d746303/readability/utils/text.py#L57
Original file line number Diff line number Diff line change @@ -97,6 +97,25 @@ describe('Resource', () => {
9797 } , / c o n t e n t d o e s n o t a p p e a r t o b e t e x t / i) ;
9898 } ) ;
9999
100+ it ( 'throws an error if the response has no Content-Type header' , ( ) => {
101+ const response = {
102+ headers : { } ,
103+ } ;
104+ const body = '' ;
105+
106+ // This assertion is more elaborate than the others to be sure that we're
107+ // throwing an `Error` and not raising a runtime exception.
108+ assert . throws (
109+ ( ) => {
110+ Resource . generateDoc ( { body, response } ) ;
111+ } ,
112+ err => (
113+ ( err instanceof Error ) &&
114+ / c o n t e n t d o e s n o t a p p e a r t o b e t e x t / i. test ( err )
115+ )
116+ ) ;
117+ } ) ;
118+
100119 it ( 'throws an error if the content has no children' , ( ) => {
101120 // jquery's parser won't work this way, and this is
102121 // an outside case
You can’t perform that action at this time.
0 commit comments