@@ -82,22 +82,28 @@ class FlibustaOpdsApiHelper {
82
82
this . axiosInstance = axiosController ;
83
83
}
84
84
85
- public prepareResponseFromOpdsEntry ( entry : Array < OpdsEntry > ) : Array < SearchBooksByNameOpdsResult > {
86
- return entry . map ( ( item ) => {
87
- const {
88
- author, link, title, updated, content, category,
89
- } = item ;
90
-
91
- return {
92
- author : FlibustaOpdsApiHelper . getAuthorsFromOpdsEntry ( author ) ,
93
- title,
94
- updated,
95
- categories : FlibustaOpdsApiHelper . getCategoriesFromOpdsEntry ( category ) ,
96
- cover : FlibustaOpdsApiHelper . getCoverFromLink ( link ) ,
97
- downloads : FlibustaOpdsApiHelper . getDownloadsItemList ( link ) ,
98
- description : content [ '#text' ] ,
99
- } ;
100
- } ) ;
85
+ private prepareResponseFromOpdsObjectEntry ( entry : OpdsEntry ) : SearchBooksByNameOpdsResult {
86
+ const {
87
+ author, link, title, updated, content, category,
88
+ } = entry ;
89
+
90
+ return {
91
+ author : FlibustaOpdsApiHelper . getAuthorsFromOpdsEntry ( author ) ,
92
+ title,
93
+ updated,
94
+ categories : FlibustaOpdsApiHelper . getCategoriesFromOpdsEntry ( category ) ,
95
+ cover : FlibustaOpdsApiHelper . getCoverFromLink ( link ) ,
96
+ downloads : FlibustaOpdsApiHelper . getDownloadsItemList ( link ) ,
97
+ description : content [ '#text' ] ,
98
+ } ;
99
+ }
100
+
101
+ public prepareResponseFromOpdsEntry ( entry : Array < OpdsEntry > | OpdsEntry ) : Array < SearchBooksByNameOpdsResult > {
102
+ if ( ! Array . isArray ( entry ) ) {
103
+ return [ this . prepareResponseFromOpdsObjectEntry ( entry ) ] ;
104
+ }
105
+
106
+ return entry . map ( ( item ) => this . prepareResponseFromOpdsObjectEntry ( item ) ) ;
101
107
}
102
108
103
109
public getTotalPagesCount ( totalResults : number , itemsPerPage : number ) : number {
0 commit comments