-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(informit): added parser for informit (#760)
* added parser for informit * updated regex for doi in url --------- Co-authored-by: Karen Coombs <coombsk@oclc.org>
- Loading branch information
1 parent
2a88317
commit c03a264
Showing
3 changed files
with
61 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |