Skip to content

Commit

Permalink
fix(core/biblio): avoid double-period if author name ends with period (
Browse files Browse the repository at this point in the history
  • Loading branch information
sidvishnoi authored Nov 26, 2024
1 parent 2d5bbd3 commit 7c5a2ee
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/core/render-biblio.js
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ function stringifyReference(ref) {
if (ref.authors && ref.authors.length) {
output += ref.authors.join("; ");
if (ref.etAl) output += " et al";
output += ". ";
if (!output.endsWith(".")) output += ". ";
}
if (ref.publisher) {
output = `${output} ${endWithDot(ref.publisher)} `;
Expand Down
7 changes: 6 additions & 1 deletion tests/spec/core/biblio-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ describe("W3C — Bibliographic References", () => {
TestRef1: {
title: "Test ref title",
href: "http://test.com",
authors: ["William Shakespeare"],
authors: ["William Shakespeare Jr."],
publisher: "Publishers Inc.",
},
TestRef2: {
Expand Down Expand Up @@ -79,6 +79,11 @@ describe("W3C — Bibliographic References", () => {
expect(ref.textContent.trim()).toBe(
"evercookie - virtually irrevocable persistent cookies. Samy Kamkar. September 2010. URL: https://samy.pl/evercookie/"
);

const refWithPeriodInEnd = doc.querySelector("#bib-testref1 + dd");
expect(refWithPeriodInEnd.textContent.trim()).toBe(
"Test ref title. William Shakespeare Jr. Publishers Inc. URL: http://test.com"
);
});

it("pings biblio service to see if it's running", () => {
Expand Down

0 comments on commit 7c5a2ee

Please sign in to comment.