Skip to content

Commit

Permalink
feat(informit): added parser for informit (#760)
Browse files Browse the repository at this point in the history
* added parser for informit

* updated regex for doi in url

---------

Co-authored-by: Karen Coombs <coombsk@oclc.org>
  • Loading branch information
librarywebchic and Karen Coombs authored Oct 25, 2023
1 parent 2a88317 commit c03a264
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 0 deletions.
13 changes: 13 additions & 0 deletions informit/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"longname": "Informit",
"name": "informit",
"describe": "Recognizes the accesses to the platform Informit",
"contact": "Sean Duffy",
"pkb": false,
"docurl": "http://analyses.ezpaarse.org/platforms/63ab1628b17c4900ecfcc023",
"domains": [
"search.informit.org"
],
"version": "2023-10-24",
"status": "beta"
}
44 changes: 44 additions & 0 deletions informit/parser.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/usr/bin/env node

'use strict';
const Parser = require('../.lib/parser.js');

/**
* Recognizes the accesses to the platform Informit
* @param {Object} parsedUrl an object representing the URL to analyze
* main attributes: pathname, query, hostname
* @param {Object} ec an object representing the EC whose URL is being analyzed
* @return {Object} the result
*/
module.exports = new Parser(function analyseEC(parsedUrl, ec) {
let result = {};
let path = parsedUrl.pathname;
// uncomment this line if you need parameters
// let param = parsedUrl.query || {};

// use console.error for debuging
// console.error(parsedUrl);

let match;

if ((match = /^\/doi\/epdf\/(10.\d{4,9}\/[-._;()/:A-Z0-9]+)$/i.exec(path)) !== null) {
// https://search.informit.org/doi/epdf/10.3316/informit.273886063150734
result.rtype = 'ARTICLE';
result.mime = 'PDF';
result.unitid = match[1];
result.doi = match[1];

} else if ((match = /^\/doi\/(10.\d{4,9}\/[-._;()/:A-Z0-9]+)$/i.exec(path)) !== null) {
// https://search.informit.org/doi/10.3316/informit.273886063150734
result.rtype = 'ARTICLE';
result.mime = 'HTML';
result.unitid = match[1];
result.doi = match[1];
} else if (/^\/action\/doSearch$/i.test(path)) {
// https://search.informit.org/action/doSearch?AllField=brazil&ConceptID=
result.rtype = 'SEARCH';
result.mime = 'HTML';
}

return result;
});
4 changes: 4 additions & 0 deletions informit/test/informit.2023-10-24.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
out-doi;out-unitid;out-rtype;out-mime;in-url
;;SEARCH;HTML;https://search.informit.org/action/doSearch?AllField=brazil&ConceptID=
10.3316/informit.273886063150734;10.3316/informit.273886063150734;ARTICLE;HTML;https://search.informit.org/doi/10.3316/informit.273886063150734
10.3316/informit.273886063150734;10.3316/informit.273886063150734;ARTICLE;PDF;https://search.informit.org/doi/epdf/10.3316/informit.273886063150734

0 comments on commit c03a264

Please sign in to comment.