@ncukondo/reference-manager 0.5.1 → 0.5.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -70,12 +70,39 @@ function getDoiFromCache(doi2) {
70
70
  function cacheDoiResult(doi2, item, config2) {
71
71
  storeInCache(doiCache, doi2, item);
72
72
  }
73
+ const DOI_URL_PREFIXES$1 = [
74
+ "https://doi.org/",
75
+ "http://doi.org/",
76
+ "https://dx.doi.org/",
77
+ "http://dx.doi.org/"
78
+ ];
79
+ function normalizeDoi(doi2) {
80
+ const trimmed = doi2.trim();
81
+ if (!trimmed) {
82
+ return "";
83
+ }
84
+ const lowerInput = trimmed.toLowerCase();
85
+ for (const prefix of DOI_URL_PREFIXES$1) {
86
+ if (lowerInput.startsWith(prefix.toLowerCase())) {
87
+ return trimmed.slice(prefix.length);
88
+ }
89
+ }
90
+ return trimmed;
91
+ }
92
+ function normalizePmid(pmid2) {
93
+ const trimmed = pmid2.trim();
94
+ if (!trimmed) {
95
+ return "";
96
+ }
97
+ const normalized = trimmed.replace(/^pmid:\s*/i, "");
98
+ return normalized.trim();
99
+ }
73
100
  const EXTENSION_MAP = {
74
101
  ".json": "json",
75
102
  ".bib": "bibtex",
76
103
  ".ris": "ris"
77
104
  };
78
- const DOI_URL_PREFIXES$1 = [
105
+ const DOI_URL_PREFIXES = [
79
106
  "https://doi.org/",
80
107
  "http://doi.org/",
81
108
  "https://dx.doi.org/",
@@ -132,7 +159,7 @@ function detectSingleIdentifier(input2) {
132
159
  return "unknown";
133
160
  }
134
161
  function isDoi(input2) {
135
- for (const prefix of DOI_URL_PREFIXES$1) {
162
+ for (const prefix of DOI_URL_PREFIXES) {
136
163
  if (input2.toLowerCase().startsWith(prefix.toLowerCase())) {
137
164
  const remainder = input2.slice(prefix.length);
138
165
  return isDoiFormat(remainder);
@@ -157,7 +184,11 @@ function isPmid(input2) {
157
184
  if (!input2 || input2.length === 0) {
158
185
  return false;
159
186
  }
160
- return /^\d+$/.test(input2);
187
+ const normalized = normalizePmid(input2);
188
+ if (!normalized) {
189
+ return false;
190
+ }
191
+ return /^\d+$/.test(normalized);
161
192
  }
162
193
  function currentVersion() {
163
194
  return this.log.length;
@@ -4953,25 +4984,6 @@ async function fetchDoi(doi2) {
4953
4984
  };
4954
4985
  }
4955
4986
  }
4956
- const DOI_URL_PREFIXES = [
4957
- "https://doi.org/",
4958
- "http://doi.org/",
4959
- "https://dx.doi.org/",
4960
- "http://dx.doi.org/"
4961
- ];
4962
- function normalizeDoi(doi2) {
4963
- const trimmed = doi2.trim();
4964
- if (!trimmed) {
4965
- return "";
4966
- }
4967
- const lowerInput = trimmed.toLowerCase();
4968
- for (const prefix of DOI_URL_PREFIXES) {
4969
- if (lowerInput.startsWith(prefix.toLowerCase())) {
4970
- return trimmed.slice(prefix.length);
4971
- }
4972
- }
4973
- return trimmed;
4974
- }
4975
4987
  var moo$2 = { exports: {} };
4976
4988
  var moo$1 = moo$2.exports;
4977
4989
  var hasRequiredMoo;
@@ -9639,7 +9651,7 @@ function classifyIdentifiers(identifiers) {
9639
9651
  const unknowns = [];
9640
9652
  for (const id2 of identifiers) {
9641
9653
  if (isPmid(id2)) {
9642
- pmids.push(id2);
9654
+ pmids.push(normalizePmid(id2));
9643
9655
  } else if (isDoi(id2)) {
9644
9656
  dois.push(normalizeDoi(id2));
9645
9657
  } else {
@@ -29848,4 +29860,4 @@ export {
29848
29860
  searchReferences as s,
29849
29861
  updateReference as u
29850
29862
  };
29851
- //# sourceMappingURL=index-9dyK2f9_.js.map
29863
+ //# sourceMappingURL=index-D4Q13N-R.js.map