@@ -8,12 +8,12 @@ const getCreatorColorRating = (el: HTMLElement): CSFDColorRating => {
8
8
return parseColor ( el ?. classNames . split ( ' ' ) . pop ( ) as Colors ) ;
9
9
} ;
10
10
11
- export const getCreatorId = ( url : string ) : number => {
11
+ export const getCreatorId = ( url : string ) : number | null => {
12
12
if ( url ) {
13
13
return parseIdFromUrl ( url ) ;
14
14
}
15
15
return null ;
16
- } ;
16
+ }
17
17
18
18
export const getCreatorName = ( el : HTMLElement | null ) : string => {
19
19
return el . querySelector ( 'h1' ) . innerText . trim ( ) ;
@@ -46,22 +46,21 @@ export const getCreatorBio = (el: HTMLElement | null): string => {
46
46
return el . querySelector ( '.article-content p' ) ?. text . trim ( ) . split ( '\n' ) [ 0 ] . trim ( ) || null ;
47
47
} ;
48
48
49
- export const getCreatorPhoto = ( el : HTMLElement | null ) : string => {
50
- const image = el . querySelector ( 'img' ) . attributes . src ;
51
- return addProtocol ( image ) ;
49
+ export const getCreatorPhoto = ( el : HTMLElement | null ) : string | null => {
50
+ const src = el ? .querySelector ( 'img' ) ?. getAttribute ( ' src' ) ;
51
+ return src ? addProtocol ( src ) : null ;
52
52
} ;
53
53
54
- const parseBirthday = ( text : string ) : any => {
55
- return text . replace ( / n a r ./ g, '' ) . trim ( ) ;
56
- } ;
54
+ const parseBirthday = ( text : string ) : string => text . replace ( / n a r \. / g, '' ) . trim ( ) ;
57
55
58
- const parseAge = ( text : string ) : any => {
59
- return text . trim ( ) . replace ( / \( / g, '' ) . replace ( / l e t \) / g, '' ) . trim ( ) ;
56
+ const parseAge = ( text : string ) : number | null => {
57
+ const digits = text . replace ( / [ ^ \d ] / g, '' ) ;
58
+ return digits ? Number ( digits ) : null ;
60
59
} ;
61
60
62
- const parseBirthPlace = ( text : string ) : any => {
63
- return text . trim ( ) . replace ( / < b r > / g, '' ) . trim ( ) ;
64
- } ;
61
+ const parseBirthPlace = ( text : string ) : string =>
62
+ text . trim ( ) . replace ( / < b r > / g, '' ) . trim ( ) ;
63
+
65
64
66
65
export const getCreatorFilms = ( el : HTMLElement | null ) : CSFDCreatorScreening [ ] => {
67
66
const filmNodes = el . querySelectorAll ( '.box' ) [ 0 ] ?. querySelectorAll ( 'table tr' ) ;
0 commit comments