Chicago 17 - Excessive comma when no pages cited

I am using a slightly customized Chicago 17 Footnote style. My output style formatting for a book looks like this:

Author, Title| [Translated Title]|, vol.·Volume|, ed.·Series Editor|, trans.·Translator|, Edition.·ed.|, Number of Volumes·vols.|, ed.·Editor|, Series Title|, vol.·Series Volume| (|Place Published|: Publisher|, Date, Year|; repr.,·Reprint Edition|)| Type of Work|. URL|,·Cited Pages|

This formatting is intended to add a comma after the closing parentheses if cited pages are present, and to omit the comma if there are no cited pages. However, the output I get is incorrect when pages are not present.

Using {Eisenstadt, 2003 #1544 12-13} should produce:

Shmuel N. Eisenstadt, ed., Comparative Civilizations and Multiple Modernities: A Collection of Essays (Leiden et al.: Brill, 2003), 12-13.

And it does.

Using {Eisenstadt, 2003 #1544} should produce:

Shmuel N. Eisenstadt, ed., Comparative Civilizations and Multiple Modernities: A Collection of Essays (Leiden et al.: Brill, 2003).

Instead, it produces:

Shmuel N. Eisenstadt, ed., Comparative Civilizations and Multiple Modernities: A Collection of Essays (Leiden et al.: Brill, 2003),.

In other words, a comma appears after the parentheses even when no cited pages are given.

How do I fix this?

In your template replace all the spaces with the link adjacent character except those in field names. This should link the commas to the field, and get rid of the extra comma. It is such a long template, I can’t tell exact which comma is being kept, but it is probably the one before the Cited Pages - so that would be the one I would change first. - but then you might get a full stop (from infront of the URL field name unless that is already a link adjacent character which doesn’t show when you copy and paste here. If endnote ends up with two punctuation characters together it rationalizes it to one of them so you never get a period followed by a comma for example. I don’t know the rules of which one it keeps.