Skip to content

Commit

Permalink
Add support for the old style arxiv ID (#15)
Browse files Browse the repository at this point in the history
* Add a regex for old id format

* Simplify regexes
  • Loading branch information
aralsea authored Apr 28, 2024
1 parent a44c1b6 commit 26b01d7
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/js/popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ UIKit.use(Icons);

const TEST_URL = 'https://arxiv.org/abs/2308.04079';
const ARXIV_API = 'http://export.arxiv.org/api/query/search_query';

class UI {
constructor() {
this.setupProgressBar();
Expand Down Expand Up @@ -101,10 +100,9 @@ class UI {
if (this.isArxivUrl(url)) return this.getArXivInfo(url);
if (this.isOpenReviewUrl(url)) return this.getOpenReviewInfo(url);
}
parseArXivId(str) {
const paperId = str.match(/\d+.\d+/);
return paperId;
}
// ref: https://info.arxiv.org/help/arxiv_identifier.html
// e.g. (new id format: 2404.16782) | (old id format: hep-th/0702063)
parseArXivId = (str) => str.match(/(\d+\.\d+$)|((\w|-)+\/\d+$)/)?.[0];

setFormContents(paperTitle, abst, comment, authors) {
document.getElementById('js-title').value = paperTitle;
Expand Down Expand Up @@ -135,7 +133,7 @@ class UI {
console.log(xmlData);

const entry = xmlData.querySelector('entry');
const id = entry.querySelector('id')?.textContent.match(/\d+\.\d+/)?.[0];
const id = this.parseArXivId(entry.querySelector('id')?.textContent);
const paperTitle = entry.querySelector('title').textContent;
const abst = entry.querySelector('summary').textContent;
const authors = Array.from(entry.querySelectorAll('author')).map(
Expand Down

0 comments on commit 26b01d7

Please sign in to comment.