diff --git a/.changeset/fair-hotels-juggle.md b/.changeset/fair-hotels-juggle.md new file mode 100644 index 0000000..8886bf6 --- /dev/null +++ b/.changeset/fair-hotels-juggle.md @@ -0,0 +1,5 @@ +--- +"crossref-utils": patch +--- + +Do not add doi to deposit if it cannot be normalized diff --git a/src/cli/deposit.ts b/src/cli/deposit.ts index c130759..35af3da 100644 --- a/src/cli/deposit.ts +++ b/src/cli/deposit.ts @@ -41,6 +41,7 @@ import { curvenoteDoiData } from '../utils.js'; import { conferencePaperFromMyst, conferenceXml } from '../conference.js'; import { contributorsXmlFromMystEditors } from '../contributors.js'; import { databaseXml, datasetFromMyst } from '../dataset.js'; +import { normalize } from 'doi-utils'; type DepositType = 'conference' | 'journal' | 'preprint' | 'dataset'; @@ -93,7 +94,7 @@ export async function depositArticleFromSource(session: ISession, depositSource: } fileContents.forEach(({ references }) => { references.cite?.order.forEach((key) => { - const value = references.cite?.data[key].doi; + const value = normalize(references.cite?.data[key].doi); if (value) dois[key] = value; else session.log.warn(`Citation without DOI excluded from crossref deposit: ${key}`); }); diff --git a/src/conference.ts b/src/conference.ts index d0f16f7..68388d3 100644 --- a/src/conference.ts +++ b/src/conference.ts @@ -2,7 +2,6 @@ import type { Element } from 'xast'; import { e } from './utils.js'; import type { ConferenceOptions, ConferencePaper } from './types.js'; import type { PageFrontmatter } from 'myst-frontmatter'; -import { normalize } from 'doi-utils'; import { contributorsXmlFromMystAuthors } from './contributors.js'; import { publicationDateXml } from './dates.js'; @@ -84,7 +83,7 @@ export function conferencePaperXml({ e( 'citation_list', Object.entries(citations).map(([key, value]) => { - return e('citation', { key }, [e('doi', normalize(value))]); + return e('citation', { key }, [e('doi', value)]); }), ), ); diff --git a/src/dataset.ts b/src/dataset.ts index e59cb80..13ad50a 100644 --- a/src/dataset.ts +++ b/src/dataset.ts @@ -2,7 +2,6 @@ import type { Element } from 'xast'; import { curvenoteDoiData, e } from './utils.js'; import type { DatabaseOptions, DatasetMetadata, Titles } from './types.js'; import type { PageFrontmatter } from 'myst-frontmatter'; -import { normalize } from 'doi-utils'; import { contributorsXmlFromMystAuthors } from './contributors.js'; import { dateXml } from './dates.js'; @@ -100,7 +99,7 @@ export function datasetXml({ e( 'citation_list', Object.entries(citations).map(([key, value]) => { - return e('citation', { key }, [e('doi', normalize(value))]); + return e('citation', { key }, [e('doi', value)]); }), ), ); diff --git a/src/journal.ts b/src/journal.ts index 079f5b5..256a3a7 100644 --- a/src/journal.ts +++ b/src/journal.ts @@ -217,7 +217,7 @@ export function journalArticleXml({ e( 'citation_list', Object.entries(citations).map(([key, value]) => { - return e('citation', { key }, [e('doi', normalize(value))]); + return e('citation', { key }, [e('doi', value)]); }), ), ); diff --git a/src/preprint.ts b/src/preprint.ts index 25d33f4..b69c89c 100644 --- a/src/preprint.ts +++ b/src/preprint.ts @@ -83,7 +83,7 @@ export function preprintXml({ e( 'citation_list', Object.entries(citations).map(([key, value]) => { - return e('citation', { key }, [e('doi', normalize(value))]); + return e('citation', { key }, [e('doi', value)]); }), ), );