Skip to content

Commit 7c5a2ee

Browse files
authored
fix(core/biblio): avoid double-period if author name ends with period (#4780)
1 parent 2d5bbd3 commit 7c5a2ee

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

src/core/render-biblio.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ function stringifyReference(ref) {
232232
if (ref.authors && ref.authors.length) {
233233
output += ref.authors.join("; ");
234234
if (ref.etAl) output += " et al";
235-
output += ". ";
235+
if (!output.endsWith(".")) output += ". ";
236236
}
237237
if (ref.publisher) {
238238
output = `${output} ${endWithDot(ref.publisher)} `;

tests/spec/core/biblio-spec.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ describe("W3C — Bibliographic References", () => {
1818
TestRef1: {
1919
title: "Test ref title",
2020
href: "http://test.com",
21-
authors: ["William Shakespeare"],
21+
authors: ["William Shakespeare Jr."],
2222
publisher: "Publishers Inc.",
2323
},
2424
TestRef2: {
@@ -79,6 +79,11 @@ describe("W3C — Bibliographic References", () => {
7979
expect(ref.textContent.trim()).toBe(
8080
"evercookie - virtually irrevocable persistent cookies. Samy Kamkar. September 2010. URL: https://samy.pl/evercookie/"
8181
);
82+
83+
const refWithPeriodInEnd = doc.querySelector("#bib-testref1 + dd");
84+
expect(refWithPeriodInEnd.textContent.trim()).toBe(
85+
"Test ref title. William Shakespeare Jr. Publishers Inc. URL: http://test.com"
86+
);
8287
});
8388

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

0 commit comments

Comments
 (0)