Skip to content

Commit

Permalink
Merge pull request #10776 from erodde/10343_author_name_trailing_comma
Browse files Browse the repository at this point in the history
Trailing comma in author name causes error
  • Loading branch information
poikilotherm authored Sep 30, 2024
2 parents 4ebbfe4 + 5ff77bf commit 79365ad
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
5 changes: 5 additions & 0 deletions doc/release-notes/10343-trailing-comma.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
### Trailing commas in author name now permitted

When an author name ends on a comma (e.g. "Smith,") a dataset cannot be properly loaded when using json-ld. A null check fixes this.

For more information, see #10343.
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public static JsonObject getPersonOrOrganization(String name, boolean organizati
if (!name.replaceFirst(",", "").contains(",")) {
// contributorName=<FamilyName>, <FirstName>
String[] fullName = name.split(", ");
givenName = fullName[1];
givenName = fullName.length > 1 ? fullName[1] : null;
familyName = fullName[0];
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ public void testName() {
verifyIsPerson("kcjim11, kcjim11", "kcjim11", "kcjim11");

verifyIsPerson("Bartholomew 3, James", "James", "Bartholomew 3");
verifyIsPerson("Smith, ", null, "Smith");
verifyIsPerson("Smith,", null, "Smith");
}

private void verifyIsOrganization(String fullName) {
Expand All @@ -106,7 +108,7 @@ private void verifyIsPerson(String fullName, String givenName, String familyName
private void verifyIsPerson(String fullName, String givenName, String familyName, boolean isPerson) {
JsonObject obj = PersonOrOrgUtil.getPersonOrOrganization(fullName, false, isPerson);
System.out.println(JsonUtil.prettyPrint(obj));
assertEquals(obj.getString("fullName"),fullName);
assertEquals(obj.getString("fullName"), StringUtil.normalize(fullName));
assertTrue(obj.getBoolean("isPerson"));
assertEquals(obj.containsKey("givenName"), givenName != null);
if(obj.containsKey("givenName") && givenName != null) {
Expand Down

0 comments on commit 79365ad

Please sign in to comment.