diff --git a/index.js b/index.js index c43e18a..c2d7225 100644 --- a/index.js +++ b/index.js @@ -71,14 +71,10 @@ if (!_.isArray(unpaywallEnrichment.oa_locations)) return; unpaywall.oaLocations = unpaywallEnrichment.oa_locations.map(location => { - return { - hostType: location.host_type, - isBest: location.is_best, - license: location.license, - url: location.url, - urlForLandingPage: location.url_for_landing_page, - urlForPdf: location.url_for_pdf, - }; + const camelCasedLocation = _.mapKeys(location, function(value, key) { + return _.camelCase(key); + }); + return camelCasedLocation; }); } diff --git a/test/run.js b/test/run.js index 7e2ae21..4581f6d 100644 --- a/test/run.js +++ b/test/run.js @@ -46,6 +46,7 @@ expect(unpaywallEnrichments[0].isOa).to.equal(true); expect(unpaywallEnrichments[0].oaLocations.length).to.be.gte(0); expect(unpaywallEnrichments[0].oaLocations[0].url.indexOf('http')).to.be.equal(0); + expect(unpaywallEnrichments[0].oaLocations[0].version).to.be.equal('publishedVersion'); expect(unpaywallEnrichments[1].isOa).to.equal(false); }); });