@ -78,12 +78,18 @@ export class SearchCrossrefService {
if ( item . author ) {
entity . result . authors = [ ] ;
for ( let j = 0 ; j < item . author . length ; j ++ ) {
entity . result . authors . push ( item . author [ j ] . family + ", " + item . author [ j ] . given ) ;
let author = this . parseName ( item . author [ j ] ) ;
if ( author ) {
entity . result . authors . push ( author ) ;
}
}
}
if ( item . editor ) {
for ( let j = 0 ; j < item . editor . length ; j ++ ) {
entity . result . editors . push ( item . editor [ j ] . family + ", " + item . editor [ j ] . given ) ;
let editor = this . parseName ( item . editor [ j ] ) ;
if ( editor ) {
entity . result . authors . push ( editor ) ;
}
}
}
results . push ( entity ) ;
@ -93,4 +99,23 @@ export class SearchCrossrefService {
}
private parseName ( authorObj ) : string {
let author : string = "" ;
if ( authorObj . hasOwnProperty ( "family" ) ) {
author += authorObj . family ;
}
if ( authorObj . hasOwnProperty ( "family" ) && authorObj . hasOwnProperty ( "given" ) ) {
author += ", " ;
}
if ( authorObj . hasOwnProperty ( "given" ) ) {
author += authorObj . given ;
}
if ( ! author && authorObj . hasOwnProperty ( "name" ) ) {
author += authorObj . name ;
}
return author ;
}
}