Skip to content

Commit

Permalink
add parser for oapen
Browse files Browse the repository at this point in the history
  • Loading branch information
andrenarchy committed Apr 25, 2016
1 parent 132b080 commit 1b32502
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@ module.exports = function paperhiveSources(_options) {
}
return ret;
},
function parseOapen(url) {
var result =
/^(?:https?:\/\/)?(?:www\.)?oapen\.org\/search\?identifier=(\d*)$/
.exec(url);
if (!result) return undefined;
return {type: 'oapen', id: result[1]};
},
function parseSpringer(url) {
var regExp = new RegExp(
'^(?:https?://)?link\.springer\.com/' +
Expand Down
12 changes: 12 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,18 @@ describe('parseUrl()', function () {
});
});

it('should parse oapen URLs', function () {
var oapen = {type: 'oapen', id: '605035'};
[
'http://oapen.org/search?identifier=605035',
'https://oapen.org/search?identifier=605035',
'http://www.oapen.org/search?identifier=605035',
'https://www.oapen.org/search?identifier=605035'
].forEach(function (url) {
sources.parseUrl(url).should.eql(oapen);
});
});

it('should parse springer URL', function () {
var sll15 = {
type: 'springer',
Expand Down

0 comments on commit 1b32502

Please sign in to comment.