Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DOI: Pull DOIs from URL #2967

Merged
merged 6 commits into from
Mar 10, 2023
Merged

Conversation

AbeJellinek
Copy link
Member

If only the URL contains a DOI (or the URL contains a DOI and the body contains only that same DOI), we now detect a single journalArticle item and don't show the Select Items dialog.

Also optimized the page-scraping code a little bit by replacing Array#includes() calls (O(n^2) overall) with Set#has() (O(n) overall).

Fixes #2964

If only the URL contains a DOI (or the URL contains a DOI and the body
contains only that same DOI), we now detect a single `journalArticle`
item and don't show the Select Items dialog.

Also optimized the page-scraping code a little bit by replacing
Array#includes() calls (O(n^2) overall) with Set#has() (O(n) overall).
Copy link
Member

@dstillman dstillman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good otherwise!

@AbeJellinek
Copy link
Member Author

We can add a test for single-item detection (DOI in URL and no other DOIs on the page) if we can find an example, but I really could not. Pages with a DOI in the URL almost always contain another DOI somewhere.

@adam3smith
Copy link
Collaborator

We can add a test for single-item detection (DOI in URL and no other DOIs on the page)

I can find you an example that has the same DOI on the page but no others, would that do?

@AbeJellinek
Copy link
Member Author

Yeah, that would.

@AbeJellinek
Copy link
Member Author

Thanks! With the other fix included in that last commit, we now have two tests for single items.

@AbeJellinek AbeJellinek merged commit 48a038d into zotero:master Mar 10, 2023
@AbeJellinek AbeJellinek deleted the doi-match-url branch March 10, 2023 16:20
zoe-translates pushed a commit to zoe-translates/translators that referenced this pull request Mar 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

DOI: Detect DOI in URL?
3 participants