Skip to content

Commit

Permalink
Fix abbreviateNames to work with names without comma
Browse files Browse the repository at this point in the history
  • Loading branch information
abelgomez committed Dec 29, 2023
1 parent f039ffb commit e7883ad
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/themes/sistedes/app/shared/citations/citation-util.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,13 @@ export class Citation {
private static abbreviateNames(fullnames : string[]): string[] {
var result = new Array();
for (var fullname of fullnames) {
var surname = fullname.split(",")[0];
var name = fullname.split(",")[1].trim().split(/\s+/).map(n => n.substring(0, 1) + ".").join(" ");
result.push(surname + ", " + name);
if (!fullname.includes(",")) {
result.push(fullname);
} else {
var surname = fullname.split(",")[0];
var name = fullname.split(",")[1].trim().split(/\s+/).map(n => n.substring(0, 1) + ".").join(" ");
result.push(surname + ", " + name);
}
}
return result;
}
Expand Down

0 comments on commit e7883ad

Please sign in to comment.