@@ -31,13 +31,18 @@ export const detectContentType = (
3131 if ( mime . includes ( 'audio' ) ) {
3232 return 'audio' ;
3333 }
34+
35+ if ( mime . includes ( 'epub' ) ) {
36+ return 'epub' ;
37+ }
3438 }
39+
3540 return 'other' ;
3641} ;
3742
3843const basic = / \s ? < ! d o c t y p e h t m l > | ( < h t m l \b [ ^ > ] * > | < b o d y \b [ ^ > ] * > | < x - [ ^ > ] + > ) + / i;
3944
40- function isHtml ( string ) {
45+ function isHtml ( string : string ) {
4146 const newString = string . trim ( ) . slice ( 0 , 1000 ) ;
4247 return basic . test ( newString ) ;
4348}
@@ -55,30 +60,25 @@ export const chunksToBlob = (
5560// eslint-disable-next-line import/no-unused-modules, import/prefer-default-export
5661export const parseArrayLikeToDetails = async (
5762 content : IPFSContentMaybe ,
58- // rawDataResponse: Uint8ArrayLike | undefined,
59- // mime: string | undefined,
6063 cid : string ,
6164 onProgress ?: onProgressCallback
6265) : Promise < IPFSContentDetails > => {
6366 try {
64- // console.log('------parseArrayLikeToDetails', cid, content);
6567 const mime = content ?. meta ?. mime ;
6668 const response : IPFSContentDetails = {
6769 link : `/ipfs/${ cid } ` ,
6870 gateway : false ,
6971 cid,
7072 } ;
7173 const initialType = detectContentType ( mime ) ;
72- if ( [ 'video' , 'audio' ] . indexOf ( initialType ) > - 1 ) {
74+ if ( [ 'video' , 'audio' , 'epub' ] . indexOf ( initialType ) > - 1 ) {
7375 return { ...response , type : initialType , gateway : true } ;
7476 }
7577
7678 const rawData = content ?. result
7779 ? await getResponseResult ( content . result , onProgress )
7880 : undefined ;
7981
80- // console.log(rawData);
81-
8282 if ( ! mime ) {
8383 response . text = `Can't detect MIME for ${ cid . toString ( ) } ` ;
8484 response . gateway = true ; // ???
0 commit comments